Skip to content

Commit

Permalink
Fix decorator linting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jooste committed Nov 22, 2023
1 parent 8908e28 commit 16de03e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion bluesky/core/funcobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class FuncObject(metaclass=FuncObjectMeta):
__slots__ = ['func', 'callback']

def __init__(self, func) -> None:
self.update(func.__func__ if isinstance(func, (staticmethod, classmethod)) else func)
ifunc = inspect.unwrap(func, stop=lambda f:not isinstance(func, (staticmethod, classmethod)))
self.update(ifunc)
ufunc = inspect.unwrap(func)
setattr(getattr(ufunc, '__func__', ufunc), '__func_object__', self)

Expand Down
7 changes: 3 additions & 4 deletions bluesky/network/sharedstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This class is used to keep a shared state across client(s) and simulation node(s)
'''
import inspect
from collections import defaultdict
from enum import Enum
import numpy as np
Expand Down Expand Up @@ -205,8 +206,7 @@ def subscribe(topic:str, *, actonly=False) -> signal.Signal:
def subscriber(func=None, *, topic='', actonly=False):
''' Decorator to subscribe to a state topic. '''
def deco(func):
ifunc = func.__func__ if isinstance(func, (staticmethod, classmethod)) \
else func
ifunc = inspect.unwrap(func, stop=lambda f:not isinstance(func, (staticmethod, classmethod)))

# Subscribe to topic, and connect callback function to data change signal
subscribe((topic or ifunc.__name__).upper(), actonly=actonly).connect(ifunc)
Expand Down Expand Up @@ -321,8 +321,7 @@ def payload(self, func: Callable):
# Publisher decorator?
def publisher(func: Optional[Callable] = None, *, topic='', dt=None):
def deco(func):
ifunc = func.__func__ if isinstance(func, (staticmethod, classmethod)) \
else func
ifunc = inspect.unwrap(func, stop=lambda f:not isinstance(func, (staticmethod, classmethod)))
itopic = (topic or ifunc.__name__).upper()

Publisher(itopic, dt).payload(func)
Expand Down
4 changes: 2 additions & 2 deletions bluesky/network/subscription.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
from typing import Dict
from bluesky.core.signal import Signal, SignalFactory
from bluesky.network.common import GROUPID_DEFAULT
Expand Down Expand Up @@ -108,8 +109,7 @@ def subscriber(func=None, *, topic='', directedonly=False, **kwargs):
- actonly: Only receive this data for the active node (client only)
'''
def deco(func):
ifunc = func.__func__ if isinstance(func, (staticmethod, classmethod)) \
else func
ifunc = inspect.unwrap(func, stop=lambda f:not isinstance(func, (staticmethod, classmethod)))

# Create the subscription object. Network subscriptions will be made as
# soon as the network connection is available
Expand Down

0 comments on commit 16de03e

Please sign in to comment.