Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ ignore = [
'PLR0915', # Too many statements
'PLR2004', # Magic value used in comparison
'RUF005', # Consider iterable unpacking instead of concatenation
'RUF012' # Mutable class attributes should be annotated with `typing.ClassVar`
'RUF012', # Mutable class attributes should be annotated with `typing.ClassVar`
'PLC0415', # `import` should be at the top-level of a file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this could be actually followed. By a pre-commit. But not a most..

'N801', # Class name should use CapWords convention (for internal __NULL sentinel)
]
select = [
'E', # pydocstyle
Expand Down
2 changes: 1 addition & 1 deletion src/plumpy/base/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def transition(self: Any, *a: Any, **kw: Any) -> Any:

raise EventError(
evt_label,
'Event produced invalid state transition from ' f'{initial.LABEL} to {self._state.LABEL}',
f'Event produced invalid state transition from {initial.LABEL} to {self._state.LABEL}',
)

return result
Expand Down
9 changes: 6 additions & 3 deletions src/plumpy/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def wrap(func: Callable[..., Any]) -> Callable[..., Any]:
if isinstance(func, property):
raise RuntimeError('Protected must go after @property decorator')

args = inspect.getargspec(func)[0]
args = inspect.getfullargspec(func)[0]
if len(args) == 0:
raise RuntimeError('Can only use the protected decorator on member functions')

Expand Down Expand Up @@ -45,7 +45,7 @@ def wrap(func: Callable[..., Any]) -> Callable[..., Any]:
if isinstance(func, property):
raise RuntimeError('Override must go after @property decorator')

args = inspect.getargspec(func)[0]
args = inspect.getfullargspec(func)[0]
if len(args) == 0:
raise RuntimeError('Can only use the override decorator on member functions')

Expand All @@ -67,9 +67,12 @@ def wrapped_fn(self: Any, *args: Any, **kwargs: Any) -> Callable[..., Any]:
return wrap


class __NULL: # noqa: N801
class __NULL:
def __eq__(self, other: Any) -> bool:
return isinstance(other, self.__class__)

def __hash__(self) -> int:
return id(self)


NULL = __NULL()
6 changes: 4 additions & 2 deletions src/plumpy/ports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Module for process ports"""
import abc

import collections
import copy
import inspect
Expand All @@ -9,7 +9,9 @@
import warnings
from typing import Any, Callable, Dict, Iterator, List, Mapping, MutableMapping, Optional, Sequence, Type, Union, cast

from plumpy.utils import is_mutable_property
from plumpy.utils import AttributesFrozendict, is_mutable_property, type_check

__all__ = ['UNSPECIFIED', 'InputPort', 'OutputPort', 'Port', 'PortNamespace', 'PortValidationError']

_LOGGER = logging.getLogger(__name__)
UNSPECIFIED = ()
Expand Down
2 changes: 1 addition & 1 deletion src/plumpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,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__)
return types.MethodType(obj.__func__, instance)

return obj

Expand Down
20 changes: 18 additions & 2 deletions src/plumpy/workchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@
import inspect
import logging
import re
import six
from typing import (
Any,
Callable,
Dict,
Hashable,
List,
Mapping,
MutableSequence,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
)

import kiwipy
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come this magically appeared here :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps it's just due to reordering the commits. never mind

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, Isee. it's imported only for typing:
communicator: Optional[kiwipy.Communicator] = None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plumpy depends on kiwipy in other modules anyways.. So I think this will not add extra overheads.. So it should be fine


from . import lang, mixins, persistence, process_states, processes
from .utils import PID_TYPE, SAVED_STATE_TYPE
Expand Down Expand Up @@ -248,7 +264,7 @@ def __str__(self) -> str:
class _FunctionCall(_Instruction):
def __init__(self, func: WC_COMMAND_TYPE) -> None:
try:
args = inspect.getargspec(func)[0]
args = inspect.getfullargspec(func)[0]
except TypeError:
raise TypeError(f'func is not a function, got {type(func)}')
if len(args) != 1:
Expand Down
Loading