Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 .molecule/default/files/polish/lib/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def generate(min_operator_count=3, max_operator_count=5, min_operand_value=-5, m
return ' '.join(symbols)


def validate(expression):
def validate(expression): # noqa: PLR0911
"""Validate an expression in Reverse Polish Notation. In addition to normal rules, the following restrictions apply:

* Only integers are supported
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,13 @@ ignore = [
'F403', # Star imports unable to detect undefined names
'F405', # Import may be undefined or defined from star imports
'PLC0415', # import-outside-top-level
'PLR0911', # Too many return statements
'PLR0912', # Too many branches
'PLR0913', # Too many arguments in function definition
'PLR0915', # Too many statements
'PLR2004', # Magic value used in comparison
'PLW1641', # Checks for classes that implement `__eq__` but not `__hash__`
'RUF005', # Consider iterable unpacking instead of concatenation
'RUF012', # Mutable class attributes should be annotated with `typing.ClassVar`
'RUF043', # Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
'RUF059' # Unpacked variable is never used
'RUF012' # Mutable class attributes should be annotated with `typing.ClassVar`
]
select = [
'E', # pydocstyle
Expand Down
4 changes: 2 additions & 2 deletions src/aiida/engine/processes/calcjobs/calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
__all__ = ('CalcJob',)


def validate_calc_job(inputs: Any, ctx: PortNamespace) -> str | None:
def validate_calc_job(inputs: Any, ctx: PortNamespace) -> str | None: # noqa: PLR0911
"""Validate the entire set of inputs passed to the `CalcJob` constructor.

Reasons that will cause this validation to raise an `InputValidationError`:
Expand Down Expand Up @@ -140,7 +140,7 @@ def validate_unstash_options(unstash_options: Any, _: Any) -> str | None:
return None


def validate_stash_options(stash_options: Any, _: Any) -> str | None:
def validate_stash_options(stash_options: Any, _: Any) -> str | None: # noqa: PLR0911
"""Validate the ``stash`` options."""
from aiida.common.datastructures import StashMode
from aiida.transports.transport import has_magic
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 @@ -252,7 +252,7 @@ def run_process(self) -> ToContext:

return ToContext(children=append_(node))

def inspect_process(self) -> ExitCode | None:
def inspect_process(self) -> ExitCode | None: # noqa: PLR0911
"""Analyse the results of the previous process and call the handlers when necessary.

If the process is excepted or killed, the work chain will abort. Otherwise any attached handlers will be called
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/nodes/data/array/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def prepare_header_comment(uuid, plot_info, comment_char='#'):
return '\n'.join(f'{comment_char} {line}' for line in filetext)


def find_bandgap(bandsdata, number_electrons=None, fermi_energy=None):
def find_bandgap(bandsdata, number_electrons=None, fermi_energy=None): # noqa: PLR0911
"""Tries to guess whether the bandsdata represent an insulator.
This method is meant to be used only for electronic bands (not phonons)
By default, it will try to use the occupations to guess the number of
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/orm/utils/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)


def load_node_class(type_string):
def load_node_class(type_string): # noqa: PLR0911
"""Return the `Node` sub class that corresponds to the given type string.

:param type_string: the `type` string of the node
Expand Down
4 changes: 2 additions & 2 deletions src/aiida/restapi/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def get(self, id=None, page=None):
:return: http response
"""
path, url, url_root, query_string = self.unquote_request()
resource_type, page, node_id, query_type = self.parse_path(path)
resource_type, _page, node_id, query_type = self.parse_path(path)
profile = self.parse_query_string(query_string)[-1]

try:
Expand Down Expand Up @@ -684,7 +684,7 @@ def get(self, id=None, page=None):
:return: http response
"""
path, url, url_root, query_string = self.unquote_request()
resource_type, page, node_id, query_type = self.parse_path(path)
resource_type, _page, node_id, query_type = self.parse_path(path)
profile = self.parse_query_string(query_string)[-1]

try:
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/storage/sqlite_zip/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _get_projectable_entity(
raise ValueError(f'Unknown casting key {cast}')
return entity

def get_filter_expr_from_jsonb(
def get_filter_expr_from_jsonb( # noqa: PLR0911
self, operator: str, value, attr_key: list[str], column=None, column_name=None, alias=None
):
"""Return a filter expression.
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/tools/dbimporters/plugins/icsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _parse_mineral(key, values):
return retval

@staticmethod
def _parse_volume(key, values):
def _parse_volume(key, values): # noqa: PLR0911
"""Convert volume, cell parameter and angle queries into right format.
:param key: query parameter
:param values: corresponding values
Expand Down
32 changes: 16 additions & 16 deletions src/aiida/transports/plugins/async_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ async def mkdir(self, path: str, exist_ok: bool = False, parents: bool = False):
raise FileExistsError(f'Directory already exists: {path}')

commands = self.ssh_command_generator(f'mkdir {"-p" if parents else ""} {{}}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, stderr = await self.openssh_execute(commands)

if returncode != 0:
if 'File exists' in stderr:
Expand All @@ -624,7 +624,7 @@ async def chmod(self, path: str, mode: int, follow_symlinks: bool = True):
# chmod works with octal numbers, so we have to convert the mode to octal
mode = oct(mode)[2:] # type: ignore[assignment]
commands = self.ssh_command_generator(f'chmod {"-h" if not follow_symlinks else ""} {mode} {{}}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
raise OSError(f'Failed to change permissions: {path}')
Expand All @@ -646,7 +646,7 @@ def _escape_for_glob(self, s):
async def glob(self, path: str, ignore_nonexisting: bool = True):
escaped_path = self._escape_for_glob(path)
commands = self.ssh_command_generator(f'find {escaped_path} -maxdepth 0')
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
if ignore_nonexisting:
Expand All @@ -662,14 +662,14 @@ async def symlink(self, source: str, destination: str):
"""

commands = self.ssh_command_generator('ln -s {} {}', paths=[source, destination])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
raise OSError(f'Failed to create symlink: {source} -> {destination}')

async def path_exists(self, path: str):
commands = self.ssh_command_generator('test -e {}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, stderr = await self.openssh_execute(commands)

if stderr:
self.logger.debug(f'Stderr from `test -e {path}`: {stderr}')
Expand All @@ -680,28 +680,28 @@ async def path_exists(self, path: str):

async def rmtree(self, path: str):
commands = self.ssh_command_generator('rm -rf {}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
raise OSError(f'Failed to remove path: {path}')

async def rmdir(self, path: str):
commands = self.ssh_command_generator('rmdir {}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
raise OSError('Failed to remove directory')

async def rename(self, oldpath: str, newpath: str):
commands = self.ssh_command_generator('mv {} {}', paths=[oldpath, newpath])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
raise OSError(f'Failed to rename path: {oldpath} -> {newpath}')

async def remove(self, path: str):
commands = self.ssh_command_generator('rm {}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)

if returncode != 0:
raise OSError(f'Failed to remove path: {path}')
Expand All @@ -710,25 +710,25 @@ async def listdir(self, path: str):
commands = self.ssh_command_generator('ls {}', paths=[path])
# '-d' is used prevents recursive listing of directories.
# This is useful when 'path' includes glob patterns.
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, stdout, _stderr = await self.openssh_execute(commands)
if returncode != 0:
raise FileNotFoundError
return list(stdout.strip().split())

async def isdir(self, path: str):
commands = self.ssh_command_generator('test -d {}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)
return returncode == 0

async def isfile(self, path: str):
commands = self.ssh_command_generator('test -f {}', paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
returncode, _stdout, _stderr = await self.openssh_execute(commands)
return returncode == 0

async def lstat(self, path: str):
# order of stat matters
commands = self.ssh_command_generator("stat -c '%s %u %g %a %X %Y' {}", paths=[path])
returncode, stdout, stderr = await self.openssh_execute(commands)
_returncode, stdout, _stderr = await self.openssh_execute(commands)

stdout = stdout.strip()
if not stdout:
Expand All @@ -753,7 +753,7 @@ async def get(self, remotepath: str, localpath: str, dereference: bool, preserve
if recursive:
options.append('-r')

returncode, stdout, stderr = await self.openssh_execute(
returncode, _stdout, stderr = await self.openssh_execute(
[
'scp',
*options,
Expand All @@ -775,7 +775,7 @@ async def put(self, localpath: str, remotepath: str, dereference: bool, preserve
if recursive:
options.append('-r')

returncode, stdout, stderr = await self.openssh_execute(
returncode, _stdout, stderr = await self.openssh_execute(
[
'scp',
*options,
Expand Down Expand Up @@ -829,7 +829,7 @@ async def copy(
f'perhaps the parent folder does not exist: {parent_directory}'
)

returncode, stdout, stderr = await self.openssh_execute(
returncode, _stdout, stderr = await self.openssh_execute(
[
'scp',
*options,
Expand Down
10 changes: 5 additions & 5 deletions tests/cmdline/params/types/test_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ def entities():

def test_get_by_id(entities):
"""Verify that using the ID will retrieve the correct entity."""
entity_01, entity_02, entity_03 = entities
entity_01, _entity_02, _entity_03 = entities
identifier = str(entity_01.pk)
result = CalculationParamType().convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_uuid(entities):
"""Verify that using the UUID will retrieve the correct entity."""
entity_01, entity_02, entity_03 = entities
entity_01, _entity_02, _entity_03 = entities
identifier = str(entity_01.uuid)
result = CalculationParamType().convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_label(entities):
"""Verify that using the LABEL will retrieve the correct entity."""
entity_01, entity_02, entity_03 = entities
entity_01, _entity_02, _entity_03 = entities
identifier = str(entity_01.label)
result = CalculationParamType().convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -61,7 +61,7 @@ def test_ambiguous_label_pk(entities):
Verify that using an ambiguous identifier gives precedence to the ID interpretation
Appending the special ambiguity breaker character will force the identifier to be treated as a LABEL
"""
entity_01, entity_02, entity_03 = entities
entity_01, entity_02, _entity_03 = entities
identifier = str(entity_02.label)
result = CalculationParamType().convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -77,7 +77,7 @@ def test_ambiguous_label_uuid(entities):
Verify that using an ambiguous identifier gives precedence to the UUID interpretation
Appending the special ambiguity breaker character will force the identifier to be treated as a LABEL
"""
entity_01, entity_02, entity_03 = entities
entity_01, _entity_02, entity_03 = entities
identifier = str(entity_03.label)
result = CalculationParamType().convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand Down
14 changes: 7 additions & 7 deletions tests/cmdline/params/types/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ def setup_codes(aiida_localhost):

def test_get_by_id(setup_codes, parameter_type):
"""Verify that using the ID will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_codes
entity_01, _entity_02, _entity_03 = setup_codes
identifier = f'{entity_01.pk}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_uuid(setup_codes, parameter_type):
"""Verify that using the UUID will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_codes
entity_01, _entity_02, _entity_03 = setup_codes
identifier = f'{entity_01.uuid}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_label(setup_codes, parameter_type):
"""Verify that using the LABEL will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_codes
entity_01, _entity_02, _entity_03 = setup_codes
identifier = f'{entity_01.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_fullname(setup_codes, parameter_type):
"""Verify that using the LABEL@machinename will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_codes
entity_01, _entity_02, _entity_03 = setup_codes
identifier = f'{entity_01.label}@{entity_01.computer.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -85,7 +85,7 @@ def test_ambiguous_label_pk(setup_codes, parameter_type):
Verify that using an ambiguous identifier gives precedence to the ID interpretation
Appending the special ambiguity breaker character will force the identifier to be treated as a LABEL
"""
entity_01, entity_02, entity_03 = setup_codes
entity_01, entity_02, _entity_03 = setup_codes
identifier = f'{entity_02.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -101,7 +101,7 @@ def test_ambiguous_label_uuid(setup_codes, parameter_type):
Verify that using an ambiguous identifier gives precedence to the UUID interpretation
Appending the special ambiguity breaker character will force the identifier to be treated as a LABEL
"""
entity_01, entity_02, entity_03 = setup_codes
entity_01, _entity_02, entity_03 = setup_codes
identifier = f'{entity_03.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -113,7 +113,7 @@ def test_ambiguous_label_uuid(setup_codes, parameter_type):

def test_entry_point_validation(setup_codes):
"""Verify that when an `entry_point` is defined in the constructor, it is respected in the validation."""
entity_01, entity_02, entity_03 = setup_codes
_entity_01, entity_02, entity_03 = setup_codes
parameter_type = CodeParamType(entry_point='core.arithmetic.add')
identifier = f'{entity_02.pk}'
result = parameter_type.convert(identifier, None, None)
Expand Down
10 changes: 5 additions & 5 deletions tests/cmdline/params/types/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ def setup_groups():

def test_get_by_id(setup_groups, parameter_type):
"""Verify that using the ID will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_groups
entity_01, _entity_02, _entity_03 = setup_groups
identifier = f'{entity_01.pk}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_uuid(setup_groups, parameter_type):
"""Verify that using the UUID will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_groups
entity_01, _entity_02, _entity_03 = setup_groups
identifier = f'{entity_01.uuid}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid


def test_get_by_label(setup_groups, parameter_type):
"""Verify that using the LABEL will retrieve the correct entity."""
entity_01, entity_02, entity_03 = setup_groups
entity_01, _entity_02, _entity_03 = setup_groups
identifier = f'{entity_01.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -68,7 +68,7 @@ def test_ambiguous_label_pk(setup_groups, parameter_type):
Verify that using an ambiguous identifier gives precedence to the ID interpretation. Appending the special ambiguity
breaker character will force the identifier to be treated as a LABEL.
"""
entity_01, entity_02, entity_03 = setup_groups
entity_01, entity_02, _entity_03 = setup_groups
identifier = f'{entity_02.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand All @@ -84,7 +84,7 @@ def test_ambiguous_label_uuid(setup_groups, parameter_type):
Verify that using an ambiguous identifier gives precedence to the UUID interpretation. Appending the special
ambiguity breaker character will force the identifier to be treated as a LABEL.
"""
entity_01, entity_02, entity_03 = setup_groups
entity_01, _entity_02, entity_03 = setup_groups
identifier = f'{entity_03.label}'
result = parameter_type.convert(identifier, None, None)
assert result.uuid == entity_01.uuid
Expand Down
Loading
Loading