Fixes code smell and ignore some useless (in context) lgtm rules.
This commit is contained in:
@ -56,8 +56,8 @@ from bonobo._version import __version__
|
||||
__all__ = ["__version__"] + __all__
|
||||
with (Path(__file__).parent / "bonobo.svg").open() as f:
|
||||
__logo__ = f.read()
|
||||
__doc__ = __doc__
|
||||
__version__ = __version__
|
||||
__doc__ = __doc__ # lgtm [py/redundant-assignment]
|
||||
__version__ = __version__ # lgtm [py/redundant-assignment]
|
||||
|
||||
|
||||
def _repr_html_():
|
||||
|
||||
@ -125,14 +125,13 @@ def open_fs(fs_url=None, *args, **kwargs):
|
||||
:param str default_protocol: The protocol to use if one is not supplied in the FS URL (defaults to ``"osfs"``).
|
||||
:returns: :class:`fs.base.FS` object
|
||||
"""
|
||||
import os
|
||||
from fs.opener import open_fs as _open_fs
|
||||
from os.path import expanduser
|
||||
from os import getcwd
|
||||
|
||||
if fs_url is None:
|
||||
fs_url = getcwd()
|
||||
fs_url = os.getcwd()
|
||||
|
||||
return _open_fs(expanduser(str(fs_url)), *args, **kwargs)
|
||||
return _open_fs(os.path.expanduser(str(fs_url)), *args, **kwargs)
|
||||
|
||||
|
||||
# standard transformations
|
||||
|
||||
@ -74,7 +74,7 @@ class Lifecycle:
|
||||
self.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type=None, exc_val=None, exc_tb=None):
|
||||
def __exit__(self, exc_type=None, exc_val=None, exc_tb=None): # lgtm [py/special-method-wrong-signature]
|
||||
self.stop()
|
||||
|
||||
def get_flags_as_string(self):
|
||||
|
||||
@ -259,7 +259,9 @@ class NodeExecutionContext(BaseContext, WithStatistics):
|
||||
"""
|
||||
for message in messages:
|
||||
if not isinstance(message, Token):
|
||||
message = ensure_tuple(message, cls=self._input_type, length=self._input_length)
|
||||
message = ensure_tuple(
|
||||
message, cls=self._input_type, length=self._input_length
|
||||
) # lgtm [py/call/wrong-named-argument]
|
||||
if self._input_length is None:
|
||||
self._input_length = len(message)
|
||||
self.input.put(message)
|
||||
|
||||
@ -34,6 +34,10 @@ def _with_length_check(f):
|
||||
|
||||
|
||||
def tuple_or_const(tuple_or_mixed, *, consts=(None, False), **kwargs):
|
||||
"""
|
||||
Like ensure_tuple, but also accept as valid outputs a list of constants.
|
||||
"""
|
||||
|
||||
if tuple_or_mixed in consts:
|
||||
return tuple_or_mixed
|
||||
if isinstance(tuple_or_mixed, str):
|
||||
@ -49,10 +53,13 @@ def ensure_tuple(tuple_or_mixed, *, cls=None):
|
||||
If it's not a tuple, let's make a tuple of one item.
|
||||
Otherwise, not changed.
|
||||
|
||||
:param tuple_or_mixed:
|
||||
:return: tuple
|
||||
|
||||
:param tuple_or_mixed: material to work on.
|
||||
:param cls: type of the resulting tuple, or `tuple` if not provided.
|
||||
:param length: provided by `_with_length_check` decorator, if specified, make sure that the tuple is of this
|
||||
length (and raise a `TypeError` if not), otherwise, do nothing.
|
||||
:return: tuple (or something of type `cls`, if provided)
|
||||
"""
|
||||
|
||||
if cls is None:
|
||||
cls = tuple
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class Timer:
|
||||
self.__start = time.time()
|
||||
return self
|
||||
|
||||
def __exit__(self, type=None, value=None, traceback=None):
|
||||
def __exit__(self, type=None, value=None, traceback=None): # lgtm [py/special-method-wrong-signature]
|
||||
# Error handling here
|
||||
self.__finish = time.time()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user