Skip to content

Commit

Permalink
Bump mypy version to ~=1.13.0 (#6630)
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz authored Nov 25, 2024
1 parent a863d1e commit c93fb4f
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ notebook = [
]
pre-commit = [
'aiida-core[atomic_tools,rest,tests,tui]',
'mypy~=1.10.0',
'mypy~=1.13.0',
'packaging~=23.0',
'pre-commit~=3.5',
'sqlalchemy[mypy]~=2.0',
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/common/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ def __init__(self, getter: Callable[[SelfType], ReturnType]) -> None:
self.getter = getter

def __get__(self, instance: Any, owner: SelfType) -> ReturnType:
return self.getter(owner)
return self.getter(owner) # type: ignore[arg-type]
2 changes: 1 addition & 1 deletion src/aiida/common/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Model(BaseModel):
field_info = Field(default, **kwargs)

for key, value in (('priority', priority), ('short_name', short_name), ('option_cls', option_cls)):
if value is not None:
if value is not None and field_info is not None:
field_info.metadata.append({key: value})

return field_info
2 changes: 1 addition & 1 deletion src/aiida/engine/processes/calcjobs/calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ def presubmit(self, folder: Folder) -> CalcInfo:

def encoder(obj):
if dataclasses.is_dataclass(obj):
return dataclasses.asdict(obj)
return dataclasses.asdict(obj) # type: ignore[arg-type]
raise TypeError(f' {obj!r} is not JSON serializable')

subfolder = folder.get_subfolder('.aiida', create=True)
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/engine/processes/workchains/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


def validate_handler_overrides(
process_class: 'BaseRestartWorkChain', handler_overrides: Optional[orm.Dict], ctx: 'PortNamespace'
process_class: type['BaseRestartWorkChain'], handler_overrides: Optional[orm.Dict], ctx: 'PortNamespace'
) -> Optional[str]:
"""Validator for the ``handler_overrides`` input port of the ``BaseRestartWorkChain``.
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/manage/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def create_runner(self, with_persistence: bool = True, **kwargs: Any) -> 'Runner
if with_persistence and 'persister' not in settings:
settings['persister'] = self.get_persister()

return runners.Runner(**settings)
return runners.Runner(**settings) # type: ignore[arg-type]

def create_daemon_runner(self, loop: Optional['asyncio.AbstractEventLoop'] = None) -> 'Runner':
"""Create and return a new daemon runner.
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/nodes/data/array/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def array_list_checker(array_list, array_name, orb_length):
raise exceptions.ValidationError('Tags must set a list of strings')
self.base.attributes.set('tags', tags)

def set_orbitals(self, **kwargs):
def set_orbitals(self, **kwargs): # type: ignore[override]
"""This method is inherited from OrbitalData, but is blocked here.
If used will raise a NotImplementedError
"""
Expand Down
4 changes: 2 additions & 2 deletions src/aiida/orm/nodes/data/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def remove(self, value):
self.set_list(data)
return item

def pop(self, **kwargs):
def pop(self, **kwargs): # type: ignore[override]
"""Remove and return item at index (default last)."""
data = self.get_list()
item = data.pop(**kwargs)
if not self._using_list_reference():
self.set_list(data)
return item

def index(self, value):
def index(self, value): # type: ignore[override]
"""Return first index of value.."""
return self.get_list().index(value)

Expand Down
4 changes: 1 addition & 3 deletions src/aiida/orm/nodes/data/singlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def open(self, path: FilePath, mode: t.Literal['rb']) -> t.Iterator[t.BinaryIO]:

@t.overload
@contextlib.contextmanager
def open( # type: ignore[overload-overlap]
self, path: None = None, mode: t.Literal['r'] = ...
) -> t.Iterator[t.TextIO]: ...
def open(self, path: None = None, mode: t.Literal['r'] = ...) -> t.Iterator[t.TextIO]: ...

@t.overload
@contextlib.contextmanager
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self):
def logger(self) -> Logger:
return self._logger

def get_version_info(self, plugin: str | type) -> dict[t.Any, dict[t.Any, t.Any]]:
def get_version_info(self, plugin: str | t.Any) -> dict[t.Any, dict[t.Any, t.Any]]:
"""Get the version information for a given plugin.
.. note::
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/tools/pytest_fixtures/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test(submit_and_await):
from aiida.engine import ProcessState

def factory(
submittable: 'Process' | 'ProcessBuilder' | 'ProcessNode',
submittable: type[Process] | ProcessBuilder | ProcessNode | t.Any,
state: ProcessState = ProcessState.FINISHED,
timeout: int = 20,
**kwargs,
Expand Down
2 changes: 1 addition & 1 deletion tests/cmdline/groups/test_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Model(BaseModel):
union_type: t.Union[int, float] = Field(title='Union type')
without_default: str = Field(title='Without default')
with_default: str = Field(title='With default', default='default')
with_default_factory: str = Field(title='With default factory', default_factory=lambda: True)
with_default_factory: str = Field(title='With default factory', default_factory=lambda: True) # type: ignore[assignment]


def test_list_options(entry_points):
Expand Down

0 comments on commit c93fb4f

Please sign in to comment.