From 9c8fd54efd8fcfdadeadde9180c5b61f352c879f Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Wed, 27 Nov 2024 16:12:19 +0100 Subject: [PATCH] Remove all pylint ignore annotations --- pyproject.toml | 1 - src/plumpy/__init__.py | 1 - src/plumpy/base/__init__.py | 4 +--- src/plumpy/base/state_machine.py | 26 +++++++++++++------------- src/plumpy/communications.py | 4 ++-- src/plumpy/event_helper.py | 4 ++-- src/plumpy/events.py | 8 +++----- src/plumpy/futures.py | 8 ++++---- src/plumpy/persistence.py | 12 +++++------- src/plumpy/ports.py | 32 ++++++++++++++++---------------- src/plumpy/process_comms.py | 10 ++++------ src/plumpy/process_listener.py | 2 +- src/plumpy/process_spec.py | 6 +++--- src/plumpy/process_states.py | 10 +++++----- src/plumpy/processes.py | 16 +++++----------- src/plumpy/settings.py | 1 - src/plumpy/utils.py | 14 +++++--------- src/plumpy/workchains.py | 12 ++++++------ test/base/test_statemachine.py | 2 +- 19 files changed, 76 insertions(+), 97 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a72ed921..5db2d92d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,6 @@ docs = [ pre-commit = [ 'mypy==1.13.0', 'pre-commit~=2.2', - 'pylint==2.15.8', 'types-pyyaml' ] tests = [ diff --git a/src/plumpy/__init__.py b/src/plumpy/__init__.py index 64a304c9..6f94b5bf 100644 --- a/src/plumpy/__init__.py +++ b/src/plumpy/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # mypy: disable-error-code=name-defined -# pylint: disable=undefined-variable __version__ = '0.22.3' import logging diff --git a/src/plumpy/base/__init__.py b/src/plumpy/base/__init__.py index 42b150ec..a4e3132e 100644 --- a/src/plumpy/base/__init__.py +++ b/src/plumpy/base/__init__.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -# pylint: disable=undefined-variable -# type: ignore from .state_machine import * from .utils import * -__all__ = state_machine.__all__ + utils.__all__ +__all__ = state_machine.__all__ + utils.__all__ # type: ignore[name-defined] diff --git a/src/plumpy/base/state_machine.py b/src/plumpy/base/state_machine.py index 62062d5d..e177dd13 100644 --- a/src/plumpy/base/state_machine.py +++ b/src/plumpy/base/state_machine.py @@ -18,8 +18,8 @@ _LOGGER = logging.getLogger(__name__) -LABEL_TYPE = Union[None, enum.Enum, str] # pylint: disable=invalid-name -EVENT_CALLBACK_TYPE = Callable[['StateMachine', Hashable, Optional['State']], None] # pylint: disable=invalid-name +LABEL_TYPE = Union[None, enum.Enum, str] +EVENT_CALLBACK_TYPE = Callable[['StateMachine', Hashable, Optional['State']], None] class StateMachineError(Exception): @@ -31,7 +31,7 @@ class StateEntryFailed(Exception): # noqa: N818 Failed to enter a state, can provide the next state to go to via this exception """ - def __init__(self, state: Hashable = None, *args: Any, **kwargs: Any) -> None: # pylint: disable=keyword-arg-before-vararg + def __init__(self, state: Hashable = None, *args: Any, **kwargs: Any) -> None: super().__init__('failed to enter state') self.state = state self.args = args @@ -123,7 +123,7 @@ class State: def is_terminal(cls) -> bool: return not cls.ALLOWED - def __init__(self, state_machine: 'StateMachine', *args: Any, **kwargs: Any): # pylint: disable=unused-argument + def __init__(self, state_machine: 'StateMachine', *args: Any, **kwargs: Any): """ :param state_machine: The process this state belongs to """ @@ -217,13 +217,13 @@ def get_states(cls) -> Sequence[Type[State]]: def initial_state_label(cls) -> LABEL_TYPE: cls.__ensure_built() assert cls.STATES is not None - return cls.STATES[0].LABEL # pylint: disable=unsubscriptable-object + return cls.STATES[0].LABEL @classmethod def get_state_class(cls, label: LABEL_TYPE) -> Type[State]: cls.__ensure_built() assert cls._STATES_MAP is not None - return cls._STATES_MAP[label] # pylint: disable=unsubscriptable-object + return cls._STATES_MAP[label] @classmethod def __ensure_built(cls) -> None: @@ -235,15 +235,15 @@ def __ensure_built(cls) -> None: pass cls.STATES = cls.get_states() - assert isinstance(cls.STATES, Iterable) # pylint: disable=isinstance-second-argument-not-valid-type + assert isinstance(cls.STATES, Iterable) # Build the states map cls._STATES_MAP = {} - for state_cls in cls.STATES: # pylint: disable=not-an-iterable + for state_cls in cls.STATES: assert issubclass(state_cls, State) label = state_cls.LABEL - assert label not in cls._STATES_MAP, f"Duplicate label '{label}'" # pylint: disable=unsupported-membership-test - cls._STATES_MAP[label] = state_cls # pylint: disable=unsupported-assignment-operation + assert label not in cls._STATES_MAP, f"Duplicate label '{label}'" + cls._STATES_MAP[label] = state_cls # should class initialise sealed = False? cls.sealed = True # type: ignore @@ -327,7 +327,7 @@ def transition_to(self, new_state: Union[Hashable, State, Type[State]], *args: A if self._state is not None and self._state.is_terminal(): call_with_super_check(self.on_terminated) - except Exception: # pylint: disable=broad-except + except Exception: self._transitioning = False if self._transition_failing: raise @@ -356,7 +356,7 @@ def set_debug(self, enabled: bool) -> None: def create_state(self, state_label: Hashable, *args: Any, **kwargs: Any) -> State: try: - return self.get_states_map()[state_label](self, *args, **kwargs) # pylint: disable=unsubscriptable-object + return self.get_states_map()[state_label](self, *args, **kwargs) except KeyError: raise ValueError(f'{state_label} is not a valid state') @@ -397,6 +397,6 @@ def _ensure_state_class(self, state: Union[Hashable, Type[State]]) -> Type[State return state try: - return self.get_states_map()[cast(Hashable, state)] # pylint: disable=unsubscriptable-object + return self.get_states_map()[cast(Hashable, state)] except KeyError: raise ValueError(f'{state} is not a valid state') diff --git a/src/plumpy/communications.py b/src/plumpy/communications.py index 01bac433..e1950a34 100644 --- a/src/plumpy/communications.py +++ b/src/plumpy/communications.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: # identifiers for subscribers - ID_TYPE = Hashable # pylint: disable=invalid-name + ID_TYPE = Hashable Subscriber = Callable[..., Any] # RPC subscriber params: communicator, msg RpcSubscriber = Callable[[kiwipy.Communicator, Any], Any] @@ -84,7 +84,7 @@ def _passthrough(*args: Any, **kwargs: Any) -> bool: return callback.is_filtered(sender, subject) else: - def _passthrough(*args: Any, **kwargs: Any) -> bool: # pylint: disable=unused-argument + def _passthrough(*args: Any, **kwargs: Any) -> bool: return False coro = ensure_coroutine(callback) diff --git a/src/plumpy/event_helper.py b/src/plumpy/event_helper.py index 2ff73597..47ad4956 100644 --- a/src/plumpy/event_helper.py +++ b/src/plumpy/event_helper.py @@ -7,7 +7,7 @@ if TYPE_CHECKING: from typing import Set, Type - from .process_listener import ProcessListener # pylint: disable=cyclic-import + from .process_listener import ProcessListener _LOGGER = logging.getLogger(__name__) @@ -49,5 +49,5 @@ def fire_event(self, event_function: Callable[..., Any], *args: Any, **kwargs: A for listener in list(self.listeners): try: getattr(listener, event_function.__name__)(*args, **kwargs) - except Exception as exception: # pylint: disable=broad-except + except Exception as exception: _LOGGER.error("Listener '%s' produced an exception:\n%s", listener, exception) diff --git a/src/plumpy/events.py b/src/plumpy/events.py index 79bf3440..b37241a4 100644 --- a/src/plumpy/events.py +++ b/src/plumpy/events.py @@ -16,9 +16,9 @@ ] if TYPE_CHECKING: - from .processes import Process # pylint: disable=cyclic-import + from .processes import Process -get_event_loop = asyncio.get_event_loop # pylint: disable=invalid-name +get_event_loop = asyncio.get_event_loop def set_event_loop(*args: Any, **kwargs: Any) -> None: @@ -57,12 +57,10 @@ def reset_event_loop_policy() -> None: """Reset the event loop policy to the default.""" loop = get_event_loop() - # pylint: disable=protected-access cls = loop.__class__ del cls._check_running # type: ignore del cls._nest_patched # type: ignore - # pylint: enable=protected-access asyncio.set_event_loop_policy(None) @@ -99,7 +97,7 @@ async def run(self) -> None: if not self._cancelled: try: await self._callback(*self._args, **self._kwargs) - except Exception: # pylint: disable=broad-except + except Exception: exc_info = sys.exc_info() self._process.callback_excepted(self._callback, exc_info[1], exc_info[2]) finally: diff --git a/src/plumpy/futures.py b/src/plumpy/futures.py index b25cfa79..99d03fc3 100644 --- a/src/plumpy/futures.py +++ b/src/plumpy/futures.py @@ -17,11 +17,11 @@ class InvalidStateError(Exception): """Exception for when a future or action is in an invalid state""" -copy_future = kiwipy.copy_future # pylint: disable=invalid-name -chain = kiwipy.chain # pylint: disable=invalid-name -gather = asyncio.gather # pylint: disable=invalid-name +copy_future = kiwipy.copy_future +chain = kiwipy.chain +gather = asyncio.gather -Future = asyncio.Future # pylint: disable=invalid-name +Future = asyncio.Future class CancellableAction(Future): diff --git a/src/plumpy/persistence.py b/src/plumpy/persistence.py index 64befd11..23c66a57 100644 --- a/src/plumpy/persistence.py +++ b/src/plumpy/persistence.py @@ -32,7 +32,7 @@ PersistedCheckpoint = collections.namedtuple('PersistedCheckpoint', ['pid', 'tag']) if TYPE_CHECKING: - from .processes import Process # pylint: disable=cyclic-import + from .processes import Process class Bundle(dict): @@ -350,7 +350,6 @@ def delete_process_checkpoints(self, pid: PID_TYPE) -> None: def auto_persist(*members: str) -> Callable[[SavableClsType], SavableClsType]: def wrapped(savable: SavableClsType) -> SavableClsType: - # pylint: disable=protected-access if savable._auto_persist is None: savable._auto_persist = set() else: @@ -488,7 +487,7 @@ def load_instance_state(self, saved_state: SAVED_STATE_TYPE, load_context: Optio self.load_members(self._auto_persist, saved_state, load_context) @super_check - def save_instance_state(self, out_state: SAVED_STATE_TYPE, save_context: Optional[LoadSaveContext]) -> None: # pylint: disable=unused-argument + def save_instance_state(self, out_state: SAVED_STATE_TYPE, save_context: Optional[LoadSaveContext]) -> None: self._ensure_persist_configured() if self._auto_persist is not None: self.save_members(self._auto_persist, out_state) @@ -627,10 +626,10 @@ def recreate_from(cls, saved_state: SAVED_STATE_TYPE, load_context: Optional[Loa state = saved_state['_state'] - if state == asyncio.futures._PENDING: # type: ignore # pylint: disable=protected-access + if state == asyncio.futures._PENDING: # type: ignore obj = cls(loop=loop) - if state == asyncio.futures._FINISHED: # type: ignore # pylint: disable=protected-access + if state == asyncio.futures._FINISHED: # type: ignore obj = cls(loop=loop) result = saved_state['_result'] @@ -640,14 +639,13 @@ def recreate_from(cls, saved_state: SAVED_STATE_TYPE, load_context: Optional[Loa except KeyError: obj.set_result(result) - if state == asyncio.futures._CANCELLED: # type: ignore # pylint: disable=protected-access + if state == asyncio.futures._CANCELLED: # type: ignore obj = cls(loop=loop) obj.cancel() return obj def load_instance_state(self, saved_state: SAVED_STATE_TYPE, load_context: LoadSaveContext) -> None: - # pylint: disable=attribute-defined-outside-init super().load_instance_state(saved_state, load_context) if self._callbacks: # typing says asyncio.Future._callbacks needs to be called, but in the python 3.7 code it is a simple list diff --git a/src/plumpy/ports.py b/src/plumpy/ports.py index 3ddc6554..9db537fc 100644 --- a/src/plumpy/ports.py +++ b/src/plumpy/ports.py @@ -20,7 +20,7 @@ This has been deprecated and the new signature is `validator(value, port)` where the `port` argument will be the port instance to which the validator has been assigned.""" -VALIDATOR_TYPE = Callable[[Any, 'Port'], Optional[str]] # pylint: disable=invalid-name +VALIDATOR_TYPE = Callable[[Any, 'Port'], Optional[str]] class PortValidationError(Exception): @@ -67,7 +67,7 @@ def __init__( self, name: str, valid_type: Optional[Type[Any]] = None, - help: Optional[str] = None, # pylint: disable=redefined-builtin + help: Optional[str] = None, required: bool = True, validator: Optional[VALIDATOR_TYPE] = None, ) -> None: @@ -135,7 +135,7 @@ def help(self) -> Optional[str]: return self._help @help.setter - def help(self, help: Optional[str]) -> None: # pylint: disable=redefined-builtin + def help(self, help: Optional[str]) -> None: """Set the help string for this port :param help: the help string @@ -199,9 +199,9 @@ def validate(self, value: Any, breadcrumbs: Sequence[str] = ()) -> Optional[Port spec = inspect.getfullargspec(self.validator) if len(spec[0]) == 1: warnings.warn(VALIDATOR_SIGNATURE_DEPRECATION_WARNING.format(self.validator.__name__)) - result = self.validator(value) # type: ignore # pylint: disable=not-callable + result = self.validator(value) # type: ignore else: - result = self.validator(value, self) # pylint: disable=not-callable + result = self.validator(value, self) if result is not None: assert isinstance(result, str), 'Validator returned non string type' validation_error = result @@ -234,11 +234,11 @@ def __init__( self, name: str, valid_type: Optional[Type[Any]] = None, - help: Optional[str] = None, # pylint: disable=redefined-builtin + help: Optional[str] = None, default: Any = UNSPECIFIED, required: bool = True, validator: Optional[VALIDATOR_TYPE] = None, - ) -> None: # pylint: disable=too-many-arguments + ) -> None: super().__init__( name, valid_type=valid_type, @@ -304,14 +304,14 @@ class PortNamespace(collections.abc.MutableMapping, Port): def __init__( self, name: str = '', # Note this was set to None, but that would fail if you tried to compute breadcrumbs - help: Optional[str] = None, # pylint: disable=redefined-builtin + help: Optional[str] = None, required: bool = True, validator: Optional[VALIDATOR_TYPE] = None, valid_type: Optional[Type[Any]] = None, default: Any = UNSPECIFIED, dynamic: bool = False, populate_defaults: bool = True, - ) -> None: # pylint: disable=too-many-arguments + ) -> None: """Construct a port namespace. :param name: the name of the namespace @@ -396,7 +396,7 @@ def valid_type(self, valid_type: Optional[Type[Any]]) -> None: if valid_type is not None: self.dynamic = True - super(PortNamespace, self.__class__).valid_type.fset(self, valid_type) # type: ignore # pylint: disable=no-member + super(PortNamespace, self.__class__).valid_type.fset(self, valid_type) # type: ignore @property def populate_defaults(self) -> bool: @@ -530,7 +530,7 @@ def absorb( :param namespace_options: a dictionary with mutable PortNamespace property values to override :return: list of the names of the ports that were absorbed """ - # pylint: disable=too-many-branches + if not isinstance(port_namespace, PortNamespace): raise ValueError('port_namespace has to be an instance of PortNamespace') @@ -577,7 +577,7 @@ def absorb( # absorb call that will properly consider the include and exclude rules self[port_name] = copy.copy(port) portnamespace = cast(PortNamespace, self[port_name]) - portnamespace._ports = {} # pylint: disable=protected-access + portnamespace._ports = {} portnamespace.absorb(port, sub_exclude, sub_include) else: # If include rules are specified but the port name does not appear, simply skip it @@ -612,7 +612,7 @@ def project(self, port_values: MutableMapping[str, Any]) -> MutableMapping[str, return result - def validate( # pylint: disable=arguments-differ + def validate( self, port_values: Optional[Mapping[str, Any]] = None, breadcrumbs: Sequence[str] = () ) -> Optional[PortValidationError]: """ @@ -622,7 +622,7 @@ def validate( # pylint: disable=arguments-differ :param breadcrumbs: a tuple of the path to having reached this point in validation :return: None or tuple containing 0: error string 1: tuple of breadcrumb strings to where the validation failed """ - # pylint: disable=arguments-renamed + breadcrumbs_local = (*breadcrumbs, self.name) message: Optional[str] @@ -660,9 +660,9 @@ def validate( # pylint: disable=arguments-differ spec = inspect.getfullargspec(self.validator) if len(spec[0]) == 1: warnings.warn(VALIDATOR_SIGNATURE_DEPRECATION_WARNING.format(self.validator.__name__)) - message = self.validator(port_values_clone) # type: ignore # pylint: disable=not-callable + message = self.validator(port_values_clone) # type: ignore else: - message = self.validator(port_values_clone, self) # pylint: disable=not-callable + message = self.validator(port_values_clone, self) if message is not None: assert isinstance( message, str diff --git a/src/plumpy/process_comms.py b/src/plumpy/process_comms.py index 7d2db4e1..6fb1d39a 100644 --- a/src/plumpy/process_comms.py +++ b/src/plumpy/process_comms.py @@ -24,7 +24,7 @@ ] if TYPE_CHECKING: - from .processes import Process # pylint: disable=cyclic-import + from .processes import Process ProcessResult = Any ProcessStatus = Any @@ -36,7 +36,6 @@ class Intent: """Intent constants for a process message""" - # pylint: disable=too-few-public-methods PLAY: str = 'play' PAUSE: str = 'pause' KILL: str = 'kill' @@ -261,7 +260,7 @@ async def launch_process( :param no_reply: if True, this call will be fire-and-forget, i.e. no return value :return: the result of launching the process """ - # pylint: disable=too-many-arguments + message = create_launch_body(process_class, init_args, init_kwargs, persist, loader, nowait) launch_future = self._communicator.task_send(message, no_reply=no_reply) future = await asyncio.wrap_future(launch_future) @@ -294,7 +293,7 @@ async def execute_process( :param no_reply: if True, this call will be fire-and-forget, i.e. no return value :return: the result of executing the process """ - # pylint: disable=too-many-arguments + message = create_create_body(process_class, init_args, init_kwargs, persist=True, loader=loader) create_future = self._communicator.task_send(message) @@ -412,7 +411,6 @@ def launch_process( nowait: bool = False, no_reply: bool = False, ) -> Union[None, PID_TYPE, ProcessResult]: - # pylint: disable=too-many-arguments """ Launch the process @@ -450,7 +448,7 @@ def execute_process( :param no_reply: if True, this call will be fire-and-forget, i.e. no return value :return: the result of executing the process """ - # pylint: disable=too-many-arguments + message = create_create_body(process_class, init_args, init_kwargs, persist=True, loader=loader) execute_future = kiwipy.Future() diff --git a/src/plumpy/process_listener.py b/src/plumpy/process_listener.py index d49b8994..8e1acf94 100644 --- a/src/plumpy/process_listener.py +++ b/src/plumpy/process_listener.py @@ -8,7 +8,7 @@ __all__ = ['ProcessListener'] if TYPE_CHECKING: - from .processes import Process # pylint: disable=cyclic-import + from .processes import Process @persistence.auto_persist('_params') diff --git a/src/plumpy/process_spec.py b/src/plumpy/process_spec.py index 4cb81196..00f2f3cc 100644 --- a/src/plumpy/process_spec.py +++ b/src/plumpy/process_spec.py @@ -7,9 +7,9 @@ from .ports import InputPort, OutputPort, Port, PortNamespace if TYPE_CHECKING: - from .processes import Process # pylint: disable=cyclic-import + from .processes import Process -EXPOSED_TYPE = Dict[Optional[str], Dict[Type['Process'], Sequence[str]]] # pylint: disable=invalid-name +EXPOSED_TYPE = Dict[Optional[str], Dict[Type['Process'], Sequence[str]]] class ProcessSpec: @@ -251,7 +251,7 @@ def _expose_ports( exclude: Optional[Sequence[str]], include: Optional[Sequence[str]], namespace_options: Optional[dict] = None, - ) -> None: # pylint: disable=too-many-arguments + ) -> None: """ Expose ports from a source PortNamespace of the ProcessSpec of a Process class into the destination PortNamespace of this ProcessSpec. If the namespace is specified, the ports will be exposed in that sub diff --git a/src/plumpy/process_states.py b/src/plumpy/process_states.py index f3130795..13a69877 100644 --- a/src/plumpy/process_states.py +++ b/src/plumpy/process_states.py @@ -40,7 +40,7 @@ ] if TYPE_CHECKING: - from .processes import Process # pylint: disable=cyclic-import + from .processes import Process class Interruption(Exception): # noqa: N818 @@ -146,7 +146,7 @@ def load_instance_state(self, saved_state: SAVED_STATE_TYPE, load_context: persi super().load_instance_state(saved_state, load_context) self.state_machine = load_context.process - def interrupt(self, reason: Any) -> None: # pylint: disable=unused-argument + def interrupt(self, reason: Any) -> None: pass @@ -218,7 +218,7 @@ def load_instance_state(self, saved_state: SAVED_STATE_TYPE, load_context: persi def interrupt(self, reason: Any) -> None: pass - async def execute(self) -> State: # type: ignore # pylint: disable=invalid-overridden-method + async def execute(self) -> State: # type: ignore if self._command is not None: command = self._command else: @@ -231,7 +231,7 @@ async def execute(self) -> State: # type: ignore # pylint: disable=invalid-over except Interruption: # Let this bubble up to the caller raise - except Exception: # pylint: disable=broad-except + except Exception: excepted = self.create_state(ProcessState.EXCEPTED, *sys.exc_info()[1:]) return cast(State, excepted) else: @@ -316,7 +316,7 @@ def interrupt(self, reason: Any) -> None: # This will cause the future in execute() to raise the exception self._waiting_future.set_exception(reason) - async def execute(self) -> State: # type: ignore # pylint: disable=invalid-overridden-method + async def execute(self) -> State: # type: ignore try: result = await self._waiting_future except Interruption: diff --git a/src/plumpy/processes.py b/src/plumpy/processes.py index d380bf3a..f681a9c0 100644 --- a/src/plumpy/processes.py +++ b/src/plumpy/processes.py @@ -48,8 +48,6 @@ from .process_spec import ProcessSpec from .utils import PID_TYPE, SAVED_STATE_TYPE, protected -# pylint: disable=too-many-lines - __all__ = ['Process', 'ProcessSpec', 'BundleKeys', 'TransitionFailed'] _LOGGER = logging.getLogger(__name__) @@ -64,7 +62,6 @@ class BundleKeys: """ - # pylint: disable=too-few-public-methods INPUTS_RAW = 'INPUTS_RAW' INPUTS_PARSED = 'INPUTS_PARSED' OUTPUTS = 'OUTPUTS' @@ -86,7 +83,6 @@ def ensure_not_closed(func: Callable[..., Any]) -> Callable[..., Any]: @functools.wraps(func) def func_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any: - # pylint: disable=protected-access if self._closed: raise exceptions.ClosedError('Process is closed') return func(self, *args, **kwargs) @@ -135,8 +131,6 @@ class Process(StateMachine, persistence.Savable, metaclass=ProcessStateMachineMe executed. """ - # pylint: disable=too-many-instance-attributes,too-many-public-methods - # Static class stuff ###################### _spec_class = ProcessSpec # Default placeholders, will be populated in init() @@ -511,7 +505,7 @@ def done(self) -> bool: .. deprecated:: 0.18.6 Use the `has_terminated` method instead """ - warnings.warn('method is deprecated, use `has_terminated` instead', DeprecationWarning) # pylint: disable=no-member + warnings.warn('method is deprecated, use `has_terminated` instead', DeprecationWarning) return self._state.is_terminal() # endregion @@ -890,7 +884,7 @@ def on_close(self) -> None: for cleanup in self._cleanups or []: try: cleanup() - except Exception: # pylint: disable=broad-except + except Exception: self.logger.exception('Process<%s>: Exception calling cleanup method %s', self.pid, cleanup) self._cleanups = None finally: @@ -939,7 +933,7 @@ def broadcast_receive( :param _comm: the communicator that sent the message :param msg: the message """ - # pylint: disable=unused-argument + self.logger.debug( "Process<%s>: received broadcast message '%s' with communicator '%s': %r", self.pid, subject, _comm, body ) @@ -1238,9 +1232,9 @@ async def step(self) -> None: else: self._set_interrupt_action_from_exception(exception) - except KeyboardInterrupt: # pylint: disable=try-except-raise + except KeyboardInterrupt: raise - except Exception: # pylint: disable=broad-except + except Exception: # Overwrite the next state to go to excepted directly next_state = self.create_state(process_states.ProcessState.EXCEPTED, *sys.exc_info()[1:]) self._set_interrupt_action(None) diff --git a/src/plumpy/settings.py b/src/plumpy/settings.py index 8a136dea..e863311c 100644 --- a/src/plumpy/settings.py +++ b/src/plumpy/settings.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- -# pylint: disable=invalid-name check_protected: bool = False check_override: bool = False diff --git a/src/plumpy/utils.py b/src/plumpy/utils.py index b8a8e8be..36d76bbd 100644 --- a/src/plumpy/utils.py +++ b/src/plumpy/utils.py @@ -8,7 +8,6 @@ from collections import deque from collections.abc import Mapping from typing import ( - TYPE_CHECKING, Any, Callable, Hashable, @@ -23,18 +22,15 @@ from . import lang from .settings import check_override, check_protected -if TYPE_CHECKING: - pass # pylint: disable=cyclic-import - __all__ = ['AttributesDict'] -protected = lang.protected(check=check_protected) # pylint: disable=invalid-name -override = lang.override(check=check_override) # pylint: disable=invalid-name +protected = lang.protected(check=check_protected) +override = lang.override(check=check_override) _LOGGER = logging.getLogger(__name__) -SAVED_STATE_TYPE = MutableMapping[str, Any] # pylint: disable=invalid-name -PID_TYPE = Hashable # pylint: disable=invalid-name +SAVED_STATE_TYPE = MutableMapping[str, Any] +PID_TYPE = Hashable class Frozendict(Mapping): @@ -139,7 +135,7 @@ def load_function(name: str, instance: Optional[Any] = None) -> Callable[..., An obj = load_object(name) if inspect.ismethod(obj): if instance is not None: - return obj.__get__(instance, instance.__class__) # type: ignore[attr-defined] # pylint: disable=unnecessary-dunder-call + return obj.__get__(instance, instance.__class__) # type: ignore[attr-defined] return obj diff --git a/src/plumpy/workchains.py b/src/plumpy/workchains.py index b7690c82..bd40ad38 100644 --- a/src/plumpy/workchains.py +++ b/src/plumpy/workchains.py @@ -32,9 +32,9 @@ ToContext = dict -PREDICATE_TYPE = Callable[['WorkChain'], bool] # pylint: disable=invalid-name -WC_COMMAND_TYPE = Callable[['WorkChain'], Any] # pylint: disable=invalid-name -EXIT_CODE_TYPE = int # pylint: disable=invalid-name +PREDICATE_TYPE = Callable[['WorkChain'], bool] +WC_COMMAND_TYPE = Callable[['WorkChain'], Any] +EXIT_CODE_TYPE = int class WorkChainSpec(processes.ProcessSpec): @@ -99,7 +99,7 @@ def _awaitable_done(self, awaitable: asyncio.Future) -> None: key = self._awaiting.pop(awaitable) try: self.process.ctx[key] = awaitable.result() # type: ignore - except Exception as exception: # pylint: disable=broad-except + except Exception as exception: self._waiting_future.set_exception(exception) else: if not self._awaiting: @@ -610,7 +610,7 @@ def step(self) -> Tuple[bool, Any]: Raise a _PropagateReturn exception where the value is the exit code set in the _Return instruction upon instantiation """ - raise _PropagateReturn(self._return_instruction._exit_code) # pylint: disable=protected-access + raise _PropagateReturn(self._return_instruction._exit_code) class _Return(_Instruction): @@ -677,7 +677,7 @@ def while_(condition: PREDICATE_TYPE) -> _While: return _While(condition) -return_ = _Return() # pylint: disable=invalid-name +return_ = _Return() """ A global singleton that contains a Return instruction that allows to exit out of the workchain outline directly with None as exit code diff --git a/test/base/test_statemachine.py b/test/base/test_statemachine.py index 5a8deb87..bd006146 100644 --- a/test/base/test_statemachine.py +++ b/test/base/test_statemachine.py @@ -40,7 +40,7 @@ def exit(self): super().exit() self._update_time() - def play(self, track=None): # pylint: disable=no-self-use, unused-argument + def play(self, track=None): return False def _update_time(self):