Skip to content
Open
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
2 changes: 1 addition & 1 deletion docs/source/internals/includes/snippets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get(self):
result = query.first()

# Results are returned as a dictionary, datetime objects are serialized as ISO 8601
return dict(id=result[0], ctime=result[1].isoformat(), attributes=result[2])
return {'id': result[0], 'ctime': result[1].isoformat(), 'attributes': result[2]}


class NewApi(AiidaApi):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
result = run(
ComplexParentWorkChain,
a=Int(1),
child_1=dict(b=Float(1.2), c=Bool(True)),
child_2=dict(b=Float(2.3), c=Bool(False)),
child_1={'b': Float(1.2), 'c': Bool(True)},
child_2={'b': Float(2.3), 'c': Bool(False)},
)
print(result)
# {
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ ignore = [
'RUF059' # Unpacked variable is never used
]
select = [
'C4', # flake8-comprehensions
'E', # pydocstyle
'W', # pydocstyle
'F', # pyflakes
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/commands/cmd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def verdi_config_caching(disabled):


@verdi_config.command('downgrade')
@click.argument('version', type=click.Choice(sorted(list({str(m.down_revision) for m in MIGRATIONS}))))
@click.argument('version', type=click.Choice(sorted({str(m.down_revision) for m in MIGRATIONS})))
def verdi_config_downgrade(version):
"""Print a configuration, downgraded to a specific version."""
path = Path(get_config_path())
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/commands/cmd_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def comment_show(user, nodes):
comments = [comment for comment in all_comments if comment.user.email == user.email]

if not comments:
valid_users = ', '.join(set(comment.user.email for comment in all_comments))
valid_users = ', '.join({comment.user.email for comment in all_comments})
echo.echo_warning(f'no comments found for user {user}')
echo.echo_report(f'valid users found for Node<{node.pk}>: {valid_users}')

Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/commands/cmd_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def process_repair(manager, broker, dry_run, force):
if len(process_tasks) != len(set_process_tasks):
state_inconsistent = True
echo.echo_warning('There are duplicates process tasks: ', nl=False)
echo.echo(set(x for x in process_tasks if process_tasks.count(x) > 1))
echo.echo({x for x in process_tasks if process_tasks.count(x) > 1})

if set_process_tasks.difference(set_active_processes):
state_inconsistent = True
Expand Down
6 changes: 3 additions & 3 deletions src/aiida/cmdline/commands/cmd_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def validate_entry_point_strings(_, __, value):

@verdi.command(
'run',
context_settings=dict(
ignore_unknown_options=True,
),
context_settings={
'ignore_unknown_options': True,
},
)
@click.argument('filepath', type=click.Path(exists=True, readable=True, dir_okay=False, path_type=pathlib.Path))
@click.argument('varargs', nargs=-1, type=click.UNPROCESSED)
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/params/types/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Contex
)

# Prepare some substitution values to check if it is all ok
subst = {i: 'value' for i in job_resource_keys}
subst = dict.fromkeys(job_resource_keys, 'value')
subst['tot_num_mpiprocs'] = 'value'

try:
Expand Down
4 changes: 2 additions & 2 deletions src/aiida/common/extendeddicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TestExample(FixedFieldsAttributeDict):
_valid_fields = ('a','b','c')
"""

_valid_fields: tuple[Any, ...] = tuple()
_valid_fields: tuple[Any, ...] = ()

def __init__(self, init: Mapping[str, Any] | None = None):
if init is None:
Expand Down Expand Up @@ -199,7 +199,7 @@ class TestExample(DefaultFieldsAttributeDict):
See if we want that setting a default field to None means deleting it.
"""

_default_fields: tuple[str, ...] = tuple()
_default_fields: tuple[str, ...] = ()

def validate(self) -> None:
"""Validate the keys, if any ``validate_*`` method is available."""
Expand Down
8 changes: 4 additions & 4 deletions src/aiida/manage/external/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def from_profile(cls, profile: 'Profile', **kwargs):
"""
dbinfo = DEFAULT_DBINFO.copy()
dbinfo.update(
dict(
host=profile.storage_config['database_hostname'] or DEFAULT_DBINFO['host'],
port=profile.storage_config['database_port'] or DEFAULT_DBINFO['port'],
)
{
'host': profile.storage_config['database_hostname'] or DEFAULT_DBINFO['host'],
'port': profile.storage_config['database_port'] or DEFAULT_DBINFO['port'],
}
)

return Postgres(dbinfo=dbinfo, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/computers.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _mpirun_command_validator(self, mpirun_cmd: list[str] | tuple[str, ...]) ->
except exceptions.EntryPointError:
raise exceptions.ValidationError('Unable to load the scheduler for this computer')

subst = {i: 'value' for i in job_resource_keys}
subst = dict.fromkeys(job_resource_keys, 'value')
subst['tot_num_mpiprocs'] = 'value'

try:
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

__all__ = ('EntityExtras',)

_NO_DEFAULT: Any = tuple()
_NO_DEFAULT: Any = ()


class EntityExtras:
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/nodes/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

__all__ = ('NodeAttributes',)

_NO_DEFAULT: Any = tuple()
_NO_DEFAULT: Any = ()


class NodeAttributes:
Expand Down
4 changes: 2 additions & 2 deletions src/aiida/orm/nodes/data/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _get_valid_cell(inputcell):
:raise ValueError: whenever the format is not valid.
"""
try:
the_cell = list(list(float(c) for c in i) for i in inputcell)
the_cell = [[float(c) for c in i] for i in inputcell]
if len(the_cell) != 3:
raise ValueError
if any(len(i) != 3 for i in the_cell):
Expand Down Expand Up @@ -969,7 +969,7 @@ def _validate(self):
if site.kind_name not in [k.name for k in kinds]:
raise ValidationError(f'A site has kind {site.kind_name}, but no specie with that name exists')

kinds_without_sites = set(k.name for k in kinds) - set(s.kind_name for s in sites)
kinds_without_sites = {k.name for k in kinds} - {s.kind_name for s in sites}
if kinds_without_sites:
raise ValidationError(
f'The following kinds are defined, but there are no sites with that kind: {list(kinds_without_sites)}'
Expand Down
4 changes: 2 additions & 2 deletions src/aiida/orm/nodes/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ def _query_type_string(cls) -> str: # noqa: N805

# A tuple of attribute names that can be updated even after node is stored
# Requires Sealable mixin, but needs empty tuple for base class
_updatable_attributes: tuple[str, ...] = tuple()
_updatable_attributes: tuple[str, ...] = ()

# A tuple of attribute names that will be ignored when creating the hash.
_hash_ignored_attributes: tuple[str, ...] = tuple()
_hash_ignored_attributes: tuple[str, ...] = ()

# Flag that determines whether the class can be cached.
_cachable = False
Expand Down
18 changes: 9 additions & 9 deletions src/aiida/orm/querybuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,18 @@ def append(
path_type = classifiers[0].ormclass_type_string

self._path.append(
dict(
entity_type=path_type,
orm_base=ormclass.value, # type: ignore[typeddict-item]
tag=tag,
{
'entity_type': path_type,
'orm_base': ormclass.value, # type: ignore[typeddict-item]
'tag': tag,
# for the first item joining_keyword/joining_value can be None,
# but after they always default to 'with_incoming' of the previous item
joining_keyword=joining_keyword, # type: ignore[typeddict-item]
joining_value=joining_value, # type: ignore[typeddict-item]
'joining_keyword': joining_keyword, # type: ignore[typeddict-item]
'joining_value': joining_value, # type: ignore[typeddict-item]
# same for edge_tag for which a default is applied
edge_tag=edge_tag, # type: ignore[typeddict-item]
outerjoin=outerjoin,
)
'edge_tag': edge_tag, # type: ignore[typeddict-item]
'outerjoin': outerjoin,
}
)

return self
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/utils/builders/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def new(self):
self.validate()

# Will be used at the end to check if all keys are known (those that are not None)
passed_keys = set(k for k in self._code_spec.keys() if self._code_spec[k] is not None)
passed_keys = {k for k in self._code_spec.keys() if self._code_spec[k] is not None}
used = set()

if self._get_and_count('code_type', used) == self.CodeType.STORE_AND_UPLOAD:
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/utils/calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_results(self):

def __dir__(self):
"""Add the keys of the results dictionary such that they can be autocompleted."""
return sorted(list(self.get_results().keys()))
return sorted(self.get_results().keys())

def __iter__(self):
"""Return an iterator over the keys of the result dictionary."""
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/plugins/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def get_entry_point(group: str, name: str) -> EntryPoint:
raise MissingEntryPointError(f"Entry point '{name}' not found in group '{group}'")
# If multiple entry points are found and they have different values we raise, otherwise if they all
# correspond to the same value, we simply return one of them
if len(found) > 1 and len(set(ep.value for ep in found)) != 1:
if len(found) > 1 and len({ep.value for ep in found}) != 1:
raise MultipleEntryPointError(f"Multiple entry points '{name}' found in group '{group}': {found}")
return found[name]

Expand Down
104 changes: 52 additions & 52 deletions src/aiida/restapi/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ def get(self):
headers = self.utils.build_headers(url=request.url, total_count=1)

## Build response and return it
data = dict(
method=request.method,
url=url,
url_root=url_root,
path=path,
query_string=query_string,
resource_type='Info',
data=response,
)
data = {
'method': request.method,
'url': url,
'url_root': url_root,
'path': path,
'query_string': query_string,
'resource_type': 'Info',
'data': response,
}
return self.utils.build_response(status=200, headers=headers, data=data)


Expand Down Expand Up @@ -210,7 +210,7 @@ def get(self, id=None, page=None):
if query_type == 'projectable_properties':
## Retrieve the projectable properties
projectable_properties, ordering = self.trans.get_projectable_properties()
results = dict(fields=projectable_properties, ordering=ordering)
results = {'fields': projectable_properties, 'ordering': ordering}
## Build response and return it
headers = self.utils.build_headers(url=request.url, total_count=1)

Expand All @@ -234,16 +234,16 @@ def get(self, id=None, page=None):
results = self.trans.get_results()

## Build response and return it
data = dict(
method=request.method,
url=url,
url_root=url_root,
path=request.path,
id=node_id,
query_string=query_string,
resource_type=resource_type,
data=results,
)
data = {
'method': request.method,
'url': url,
'url_root': url_root,
'path': request.path,
'id': node_id,
'query_string': query_string,
'resource_type': resource_type,
'data': results,
}

return self.utils.build_response(status=200, headers=headers, data=data)

Expand Down Expand Up @@ -459,7 +459,7 @@ def get(self, id=None, page=None):
if query_type == 'projectable_properties':
## Retrieve the projectable properties
projectable_properties, ordering = self.trans.get_projectable_properties()
results = dict(fields=projectable_properties, ordering=ordering)
results = {'fields': projectable_properties, 'ordering': ordering}
## Build response and return it
headers = self.utils.build_headers(url=request.url, total_count=1)

Expand Down Expand Up @@ -567,16 +567,16 @@ def get(self, id=None, page=None):
del node[f'extras.{extra!s}']

## Build response
data = dict(
method=request.method,
url=url,
url_root=url_root,
path=path,
id=node_id,
query_string=query_string,
resource_type=resource_type,
data=results,
)
data = {
'method': request.method,
'url': url,
'url_root': url_root,
'path': path,
'id': node_id,
'query_string': query_string,
'resource_type': resource_type,
'data': results,
}

return self.utils.build_response(status=200, headers=headers, data=data)

Expand Down Expand Up @@ -653,19 +653,19 @@ def get(self, id=None, page=None):
elif query_type == 'projectable_properties':
## Retrieve the projectable properties
projectable_properties, ordering = self.trans.get_projectable_properties()
results = dict(fields=projectable_properties, ordering=ordering)
results = {'fields': projectable_properties, 'ordering': ordering}

## Build response
data = dict(
method=request.method,
url=url,
url_root=url_root,
path=path,
id=node_id,
query_string=query_string,
resource_type=resource_type,
data=results,
)
data = {
'method': request.method,
'url': url,
'url_root': url_root,
'path': path,
'id': node_id,
'query_string': query_string,
'resource_type': resource_type,
'data': results,
}

return self.utils.build_response(status=200, headers=headers, data=data)

Expand Down Expand Up @@ -719,15 +719,15 @@ def get(self, id=None, page=None):
headers = self.utils.build_headers(url=request.url, total_count=1)

## Build response
data = dict(
method=request.method,
url=url,
url_root=url_root,
path=path,
id=node_id,
query_string=query_string,
resource_type=resource_type,
data=results,
)
data = {
'method': request.method,
'url': url,
'url_root': url_root,
'path': path,
'id': node_id,
'query_string': query_string,
'resource_type': resource_type,
'data': results,
}

return self.utils.build_response(status=200, headers=headers, data=data)
2 changes: 1 addition & 1 deletion src/aiida/restapi/translator/nodes/data/kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_derived_properties(node):
# kpoints)
# tab_mesh: whether to include a table with the mesh and offsets

bool_fields = dict(has_cell=has_cell, has_mesh=has_mesh, has_labels=has_labels)
bool_fields = {'has_cell': has_cell, 'has_mesh': has_mesh, 'has_labels': has_labels}

response.update(bool_fields)

Expand Down
2 changes: 1 addition & 1 deletion src/aiida/schedulers/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class JobResource(DefaultFieldsAttributeDict, metaclass=abc.ABCMeta):
The init should raise only ValueError or TypeError on invalid parameters.
"""

_default_fields = tuple()
_default_fields: tuple[str, ...] = ()

@classmethod
@abc.abstractmethod
Expand Down
Loading
Loading