Skip to content
Merged
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
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ ignore = [
'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/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
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
6 changes: 3 additions & 3 deletions tests/cmdline/utils/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ def test_validate_output_filename():
expected_output_file = Path(f'{test_entity_label}{test_appendix}.{fileformat}')

# Test failure if no actual file to be validated is passed
with pytest.raises(TypeError, match='.*passed for validation.'):
with pytest.raises(TypeError, match=r'.*passed for validation'):
validate_output_filename(output_file=None)

# Test failure if file exists, but overwrite False
expected_output_file.touch()
with pytest.raises(FileExistsError, match='.*use `--overwrite` to overwrite.'):
with pytest.raises(FileExistsError, match=r'.*use `--overwrite` to overwrite'):
validate_output_filename(output_file=expected_output_file, overwrite=False)

# Test that overwrite does the job -> No exception raised
Expand All @@ -118,7 +118,7 @@ def test_validate_output_filename():

# Test failure if directory exists
expected_output_file.mkdir()
with pytest.raises(IsADirectoryError, match='A directory with the name.*'):
with pytest.raises(IsADirectoryError, match='A directory with the name'):
validate_output_filename(
output_file=expected_output_file,
overwrite=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ def setup_multiply_add_group(generate_workchain_multiply_add) -> orm.Group:
@pytest.fixture()
def setup_duplicate_group():
def _setup_duplicate_group(source_group: orm.Group, dest_group_label: str):
dupl_group, created = orm.Group.collection.get_or_create(label=dest_group_label)
dupl_group, _created = orm.Group.collection.get_or_create(label=dest_group_label)
dupl_group.add_nodes(list(source_group.nodes))
return dupl_group

Expand Down
4 changes: 2 additions & 2 deletions tests/engine/daemon/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_get_daemon_client_does_not_switch_profile(empty_config, profile_factory

def test_get_status_daemon_not_running(stopped_daemon_client):
"""Test ``DaemonClient.get_status`` output when the daemon is not running."""
with pytest.raises(DaemonNotRunningException, match='The daemon is not running.'):
with pytest.raises(DaemonNotRunningException, match='The daemon is not running'):
stopped_daemon_client.get_status()


Expand All @@ -103,7 +103,7 @@ def raise_daemon_timeout():
@patch.object(DaemonClient, 'get_status', lambda _: raise_daemon_timeout())
def test_get_status_timeout(stopped_daemon_client):
"""Test ``DaemonClient.get_status`` output when the circus daemon process cannot be reached."""
with pytest.raises(DaemonTimeoutException, match='Connection to the daemon timed out.'):
with pytest.raises(DaemonTimeoutException, match='Connection to the daemon timed out'):
stopped_daemon_client.get_status()


Expand Down
2 changes: 1 addition & 1 deletion tests/engine/processes/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_processes_all_exclusivity(submit_and_await, action):
node = submit_and_await(WaitProcess, ProcessState.WAITING)
assert not node.paused

with pytest.raises(ValueError, match='cannot specify processes when `all_entries = True`.'):
with pytest.raises(ValueError, match='cannot specify processes when `all_entries = True`'):
action([node], all_entries=True)


Expand Down
2 changes: 1 addition & 1 deletion tests/engine/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ def test_run():
def test_run_get_node(self):
"""Test the `run_get_node` function."""
inputs = {'a': Int(2), 'b': Str('test')}
result, node = run_get_node(DummyProcess, **inputs)
_result, node = run_get_node(DummyProcess, **inputs)
assert isinstance(node, ProcessNode)
2 changes: 1 addition & 1 deletion tests/engine/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_submit(runner):
"""Test that inputs can be specified either as a positional dictionary or through keyword arguments."""
inputs = {'a': Str('input')}

with pytest.raises(ValueError, match='Cannot specify both `inputs` and `kwargs`.'):
with pytest.raises(ValueError, match='Cannot specify both `inputs` and `kwargs`'):
runner.submit(Proc, inputs, **inputs)

runner.submit(Proc, inputs)
Expand Down
Loading
Loading