Skip to content

Commit 51044e8

Browse files
in-progress
1 parent c0e3c82 commit 51044e8

File tree

93 files changed

+2229
-2099
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2229
-2099
lines changed

src/aiida/cmdline/utils/common.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_env_with_venv_bin() -> MutableMapping:
6464
config = get_config()
6565

6666
currenv = os.environ.copy()
67-
currenv['PATH'] = f"{os.path.dirname(sys.executable)}:{currenv['PATH']}"
67+
currenv['PATH'] = f'{os.path.dirname(sys.executable)}:{currenv["PATH"]}'
6868
currenv['AIIDA_PATH'] = config.dirpath
6969
currenv['PYTHONUNBUFFERED'] = 'True'
7070

@@ -180,18 +180,18 @@ def get_node_info(node: orm.Node, include_summary: bool = True) -> str:
180180
nodes_output = node.base.links.get_outgoing(link_type=(LinkType.CREATE, LinkType.RETURN))
181181

182182
if nodes_input:
183-
result += f"\n{format_nested_links(nodes_input.nested(), headers=['Inputs', 'PK', 'Type'])}"
183+
result += f'\n{format_nested_links(nodes_input.nested(), headers=["Inputs", "PK", "Type"])}'
184184

185185
if nodes_output:
186-
result += f"\n{format_nested_links(nodes_output.nested(), headers=['Outputs', 'PK', 'Type'])}"
186+
result += f'\n{format_nested_links(nodes_output.nested(), headers=["Outputs", "PK", "Type"])}'
187187

188188
if nodes_caller:
189189
links = sorted(nodes_caller.all(), key=lambda x: x.node.ctime)
190-
result += f"\n{format_flat_links(links, headers=['Caller', 'PK', 'Type'])}"
190+
result += f'\n{format_flat_links(links, headers=["Caller", "PK", "Type"])}'
191191

192192
if nodes_called:
193193
links = sorted(nodes_called.all(), key=lambda x: x.node.ctime)
194-
result += f"\n{format_flat_links(links, headers=['Called', 'PK', 'Type'])}"
194+
result += f'\n{format_flat_links(links, headers=["Called", "PK", "Type"])}'
195195

196196
log_messages = orm.Log.collection.get_logs_for(node)
197197

@@ -253,7 +253,7 @@ def format_recursive(links, depth=0):
253253
table = []
254254

255255
for depth, label, pk, class_name in format_recursive(links):
256-
table.append([f"{' ' * (depth * indent_size)}{label}", pk, class_name])
256+
table.append([f'{" " * (depth * indent_size)}{label}', pk, class_name])
257257

258258
result = f'\n{tabulate(table, headers=headers)}'
259259
tb.PRESERVE_WHITESPACE = False
@@ -279,7 +279,7 @@ def get_calcjob_report(calcjob: orm.CalcJobNode) -> str:
279279
report = []
280280

281281
if calcjob_state == CalcJobState.WITHSCHEDULER:
282-
state_string = f"{calcjob_state}, scheduler state: {scheduler_state if scheduler_state else '(unknown)'}"
282+
state_string = f'{calcjob_state}, scheduler state: {scheduler_state if scheduler_state else "(unknown)"}'
283283
else:
284284
state_string = f'{calcjob_state}'
285285

src/aiida/common/typing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
from __future__ import annotations
1212

1313
import pathlib
14+
import sys
1415
from typing import Union
1516

16-
try:
17+
if sys.version_info >= (3, 11):
1718
from typing import Self
18-
except ImportError:
19+
else:
1920
from typing_extensions import Self
2021

2122
__all__ = ('FilePath', 'Self')

src/aiida/orm/authinfos.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from __future__ import annotations
1212

13-
from typing import TYPE_CHECKING, Any, Dict, Optional, Type
13+
from typing import TYPE_CHECKING, Any, cast
1414

1515
from aiida.common import exceptions
1616
from aiida.common.pydantic import MetadataField
@@ -33,7 +33,7 @@ class AuthInfoCollection(entities.Collection['AuthInfo']):
3333
"""The collection of `AuthInfo` entries."""
3434

3535
@staticmethod
36-
def _entity_base_cls() -> Type['AuthInfo']:
36+
def _entity_base_cls() -> type['AuthInfo']:
3737
return AuthInfo
3838

3939
def delete(self, pk: int) -> None:
@@ -55,25 +55,25 @@ class Model(entities.Entity.Model):
5555
description='The PK of the computer',
5656
is_attribute=False,
5757
orm_class=Computer,
58-
orm_to_model=lambda auth_info, _: auth_info.computer.pk, # type: ignore[attr-defined]
58+
orm_to_model=lambda auth_info, _: cast('AuthInfo', auth_info).computer.pk,
5959
)
6060
user: int = MetadataField(
6161
description='The PK of the user',
6262
is_attribute=False,
6363
orm_class=User,
64-
orm_to_model=lambda auth_info, _: auth_info.user.pk, # type: ignore[attr-defined]
64+
orm_to_model=lambda auth_info, _: cast('AuthInfo', auth_info).user.pk,
6565
)
6666
enabled: bool = MetadataField(
6767
True,
6868
description='Whether the instance is enabled',
6969
is_attribute=False,
7070
)
71-
auth_params: Dict[str, Any] = MetadataField(
71+
auth_params: dict[str, Any] = MetadataField(
7272
default_factory=dict,
7373
description='Dictionary of authentication parameters',
7474
is_attribute=False,
7575
)
76-
metadata: Dict[str, Any] = MetadataField(
76+
metadata: dict[str, Any] = MetadataField(
7777
default_factory=dict,
7878
description='Dictionary of metadata',
7979
is_attribute=False,
@@ -84,9 +84,9 @@ def __init__(
8484
computer: 'Computer',
8585
user: 'User',
8686
enabled: bool = True,
87-
auth_params: Dict[str, Any] | None = None,
88-
metadata: Dict[str, Any] | None = None,
89-
backend: Optional['StorageBackend'] = None,
87+
auth_params: dict[str, Any] | None = None,
88+
metadata: dict[str, Any] | None = None,
89+
backend: 'StorageBackend' | None = None,
9090
) -> None:
9191
"""Create an `AuthInfo` instance for the given computer and user.
9292
@@ -151,35 +151,35 @@ def user(self) -> 'User':
151151
return entities.from_backend_entity(users.User, self._backend_entity.user)
152152

153153
@property
154-
def auth_params(self) -> Dict[str, Any]:
154+
def auth_params(self) -> dict[str, Any]:
155155
return self._backend_entity.get_auth_params()
156156

157157
@property
158-
def metadata(self) -> Dict[str, Any]:
158+
def metadata(self) -> dict[str, Any]:
159159
return self._backend_entity.get_metadata()
160160

161-
def get_auth_params(self) -> Dict[str, Any]:
161+
def get_auth_params(self) -> dict[str, Any]:
162162
"""Return the dictionary of authentication parameters
163163
164164
:return: a dictionary with authentication parameters
165165
"""
166166
return self._backend_entity.get_auth_params()
167167

168-
def set_auth_params(self, auth_params: Dict[str, Any]) -> None:
168+
def set_auth_params(self, auth_params: dict[str, Any]) -> None:
169169
"""Set the dictionary of authentication parameters
170170
171171
:param auth_params: a dictionary with authentication parameters
172172
"""
173173
self._backend_entity.set_auth_params(auth_params)
174174

175-
def get_metadata(self) -> Dict[str, Any]:
175+
def get_metadata(self) -> dict[str, Any]:
176176
"""Return the dictionary of metadata
177177
178178
:return: a dictionary with metadata
179179
"""
180180
return self._backend_entity.get_metadata()
181181

182-
def set_metadata(self, metadata: Dict[str, Any]) -> None:
182+
def set_metadata(self, metadata: dict[str, Any]) -> None:
183183
"""Set the dictionary of metadata
184184
185185
:param metadata: a dictionary with metadata

src/aiida/orm/comments.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
###########################################################################
99
"""Comment objects and functions"""
1010

11+
from __future__ import annotations
12+
1113
from datetime import datetime
12-
from typing import TYPE_CHECKING, List, Optional, Type, cast
14+
from typing import TYPE_CHECKING, Optional, cast
1315

1416
from aiida.common.pydantic import MetadataField
1517
from aiida.manage import get_manager
@@ -29,7 +31,7 @@ class CommentCollection(entities.Collection['Comment']):
2931
"""The collection of Comment entries."""
3032

3133
@staticmethod
32-
def _entity_base_cls() -> Type['Comment']:
34+
def _entity_base_cls() -> type['Comment']:
3335
return Comment
3436

3537
def delete(self, pk: int) -> None:
@@ -49,7 +51,7 @@ def delete_all(self) -> None:
4951
"""
5052
self._backend.comments.delete_all()
5153

52-
def delete_many(self, filters: dict) -> List[int]:
54+
def delete_many(self, filters: dict) -> list[int]:
5355
"""Delete Comments from the Collection based on ``filters``
5456
5557
:param filters: similar to QueryBuilder filter
@@ -69,13 +71,22 @@ class Comment(entities.Entity['BackendComment', CommentCollection]):
6971

7072
class Model(entities.Entity.Model):
7173
uuid: Optional[str] = MetadataField(
72-
description='The UUID of the comment', is_attribute=False, exclude_to_orm=True
74+
None,
75+
description='The UUID of the comment',
76+
is_attribute=False,
77+
exclude_to_orm=True,
7378
)
7479
ctime: Optional[datetime] = MetadataField(
75-
description='Creation time of the comment', is_attribute=False, exclude_to_orm=True
80+
None,
81+
description='Creation time of the comment',
82+
is_attribute=False,
83+
exclude_to_orm=True,
7684
)
7785
mtime: Optional[datetime] = MetadataField(
78-
description='Modified time of the comment', is_attribute=False, exclude_to_orm=True
86+
None,
87+
description='Modified time of the comment',
88+
is_attribute=False,
89+
exclude_to_orm=True,
7990
)
8091
node: int = MetadataField(
8192
description='Node PK that the comment is attached to',
@@ -89,10 +100,17 @@ class Model(entities.Entity.Model):
89100
orm_class='core.user',
90101
orm_to_model=lambda comment, _: cast('Comment', comment).user.pk,
91102
)
92-
content: str = MetadataField(description='Content of the comment', is_attribute=False)
103+
content: str = MetadataField(
104+
description='Content of the comment',
105+
is_attribute=False,
106+
)
93107

94108
def __init__(
95-
self, node: 'Node', user: 'User', content: Optional[str] = None, backend: Optional['StorageBackend'] = None
109+
self,
110+
node: 'Node',
111+
user: 'User',
112+
content: str | None = None,
113+
backend: 'StorageBackend' | None = None,
96114
):
97115
"""Create a Comment for a given node and user
98116

0 commit comments

Comments
 (0)