Skip to content

Commit 732dd0f

Browse files
committed
Bump mypy to 1.16.0
1 parent edb8c7e commit 732dd0f

File tree

9 files changed

+71
-55
lines changed

9 files changed

+71
-55
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ notebook = [
229229
]
230230
pre-commit = [
231231
'aiida-core[atomic_tools,rest,tests,tui]',
232-
'mypy~=1.13.0',
232+
'mypy~=1.16.0',
233233
'packaging~=23.0',
234234
'pre-commit~=3.5',
235235
'sqlalchemy[mypy]~=2.0',

src/aiida/cmdline/commands/cmd_profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ def profile_setup():
122122
"""Set up a new profile."""
123123

124124

125-
@verdi_profile.command('configure-rabbitmq') # type: ignore[arg-type]
125+
@verdi_profile.command('configure-rabbitmq')
126+
@click.pass_context
126127
@arguments.PROFILE(default=defaults.get_default_profile)
127128
@options.FORCE()
129+
@options.NON_INTERACTIVE(default=True, show_default='--non-interactive')
128130
@setup.SETUP_BROKER_PROTOCOL()
129131
@setup.SETUP_BROKER_USERNAME()
130132
@setup.SETUP_BROKER_PASSWORD()
131133
@setup.SETUP_BROKER_HOST()
132134
@setup.SETUP_BROKER_PORT()
133135
@setup.SETUP_BROKER_VIRTUAL_HOST()
134-
@options.NON_INTERACTIVE(default=True, show_default='--non-interactive')
135-
@click.pass_context
136136
def profile_configure_rabbitmq(ctx, profile, non_interactive, force, **kwargs):
137137
"""Configure RabbitMQ for a profile.
138138

src/aiida/engine/processes/functions.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,11 @@ def build(func: FunctionType, node_class: t.Type['ProcessNode']) -> t.Type['Func
355355
"""
356356
if (
357357
not issubclass(node_class, ProcessNode) # type: ignore[redundant-expr]
358-
or not issubclass(node_class, FunctionCalculationMixin) # type: ignore[unreachable]
358+
or not issubclass(node_class, FunctionCalculationMixin)
359359
):
360360
raise TypeError('the node_class should be a sub class of `ProcessNode` and `FunctionCalculationMixin`')
361361

362-
signature = inspect.signature(func) # type: ignore[unreachable]
362+
signature = inspect.signature(func)
363363

364364
args: list[str] = []
365365
var_positional: str | None = None
@@ -373,17 +373,21 @@ def build(func: FunctionType, node_class: t.Type['ProcessNode']) -> t.Type['Func
373373
LOGGER.warning(f'function `{func.__name__}` has invalid type hints: {exception}')
374374
annotations = {}
375375

376-
try:
377-
parsed_docstring = docstring_parser.parse(func.__doc__)
378-
except Exception as exception:
379-
LOGGER.warning(f'function `{func.__name__}` has a docstring that could not be parsed: {exception}')
380-
param_help_string = {}
376+
if func.__doc__ is None:
377+
param_help_string: dict[str, str | None] = {}
381378
namespace_help_string = None
382379
else:
383-
param_help_string = {param.arg_name: param.description for param in parsed_docstring.params}
384-
namespace_help_string = parsed_docstring.short_description if parsed_docstring.short_description else ''
385-
if parsed_docstring.long_description is not None:
386-
namespace_help_string += f'\n\n{parsed_docstring.long_description}'
380+
try:
381+
parsed_docstring = docstring_parser.parse(func.__doc__)
382+
except Exception as exception:
383+
LOGGER.warning(f'function `{func.__name__}` has a docstring that could not be parsed: {exception}')
384+
param_help_string = {}
385+
namespace_help_string = None
386+
else:
387+
param_help_string = {param.arg_name: param.description for param in parsed_docstring.params}
388+
namespace_help_string = parsed_docstring.short_description if parsed_docstring.short_description else ''
389+
if parsed_docstring.long_description is not None:
390+
namespace_help_string += f'\n\n{parsed_docstring.long_description}'
387391

388392
for key, parameter in signature.parameters.items():
389393
if parameter.kind in [parameter.POSITIONAL_ONLY, parameter.POSITIONAL_OR_KEYWORD, parameter.KEYWORD_ONLY]:
@@ -435,7 +439,7 @@ def define(cls, spec):
435439
def indirect_default(value=default):
436440
return to_aiida_type(value)
437441
else:
438-
indirect_default = default
442+
indirect_default = default # type: ignore[assignment]
439443

440444
spec.input(
441445
parameter.name,

src/aiida/engine/processes/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Process(PlumpyProcess):
8080
class SaveKeys(enum.Enum):
8181
"""Keys used to identify things in the saved instance state bundle."""
8282

83-
CALC_ID: str = 'calc_id'
83+
CALC_ID = 'calc_id'
8484

8585
@classmethod
8686
def spec(cls) -> ProcessSpec:

src/aiida/orm/nodes/data/code/installed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def get_executable(self) -> pathlib.PurePath:
159159
"""
160160
return self.filepath_executable
161161

162-
@property # type: ignore[override]
162+
@property
163163
def computer(self) -> Computer:
164164
"""Return the computer of this code."""
165165
assert self.backend_entity.computer is not None

src/aiida/orm/nodes/process/calculation/calcfunction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def validate_outgoing(self, target: 'Node', link_type: LinkType, link_label: str
4747
)
4848

4949

50-
class CalcFunctionNode(FunctionCalculationMixin, CalculationNode): # type: ignore[misc]
50+
class CalcFunctionNode(FunctionCalculationMixin, CalculationNode):
5151
"""ORM class for all nodes representing the execution of a calcfunction."""
5252

5353
_CLS_NODE_LINKS = CalcFunctionNodeLinks

src/aiida/orm/nodes/process/workflow/workfunction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def validate_outgoing(self, target: 'Node', link_type: LinkType, link_label: str
4545
)
4646

4747

48-
class WorkFunctionNode(FunctionCalculationMixin, WorkflowNode): # type: ignore[misc]
48+
class WorkFunctionNode(FunctionCalculationMixin, WorkflowNode):
4949
"""ORM class for all nodes representing the execution of a workfunction."""
5050

5151
_CLS_NODE_LINKS = WorkFunctionNodeLinks

src/aiida/repository/backend/abstract.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ def put_object_from_filelike(self, handle: BinaryIO) -> str:
7575
:return: the generated fully qualified identifier for the object within the repository.
7676
:raises TypeError: if the handle is not a byte stream.
7777
"""
78-
if (
79-
not isinstance(handle, io.BufferedIOBase) # type: ignore[redundant-expr,unreachable]
80-
and not self.is_readable_byte_stream(handle)
81-
):
78+
if not isinstance(handle, io.BufferedIOBase) and not self.is_readable_byte_stream(handle):
8279
raise TypeError(f'handle does not seem to be a byte stream: {type(handle)}.')
8380
return self._put_object_from_filelike(handle)
8481

0 commit comments

Comments
 (0)