Skip to content

Commit

Permalink
DevOps: Update requirement pylint~=2.17.4 (#6054)
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber authored Jun 15, 2023
1 parent add474c commit 3976344
Show file tree
Hide file tree
Showing 187 changed files with 263 additions and 339 deletions.
2 changes: 1 addition & 1 deletion .github/system_tests/workchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def disabled_handler(self, node): # pylint: disable=unused-argument
return ProcessHandlerReport(True, self.exit_codes.ERROR_ENABLED_DOOM) # pylint: disable=no-member

@process_handler(priority=450, exit_codes=ExitCode(1000, 'Unicorn encountered'))
def a_magic_unicorn_appeared(self, node): # pylint: disable=no-self-argument,no-self-use
def a_magic_unicorn_appeared(self, node): # pylint: disable=no-self-argument
"""As we all know unicorns do not exist so we should never have to deal with it."""
raise RuntimeError('this handler should never even have been called')

Expand Down
4 changes: 2 additions & 2 deletions .molecule/default/files/polish/lib/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def validate(expression):
except ValueError:
return False, f'the operand {operand} is not a valid integer'

if operator not in OPERATORS.keys():
if operator not in OPERATORS:
return False, f'the operator {operator} is not supported'

if OPERATORS[operator] is operators.pow and operand < 0:
Expand Down Expand Up @@ -119,7 +119,7 @@ def evaluate(expression, modulo=None):
result = 0

for part in expression.split():
if part not in OPERATORS.keys():
if part not in OPERATORS:
stack.appendleft(part)
else:
operator = OPERATORS[part]
Expand Down
4 changes: 2 additions & 2 deletions .molecule/default/files/polish/lib/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def generate_outlines(expression):

for part in expression.split():

if part not in OPERATORS.keys():
if part not in OPERATORS:
stack.appendleft(part)
values.append(part)
else:
Expand Down Expand Up @@ -222,7 +222,7 @@ def write_workchain(outlines, directory=None) -> Path:

outline_string = ''
for subline in outline.split('\n'):
outline_string += f'\t\t\t{subline}\n'
outline_string += f'\t\t\t{subline}\n' # pylint: disable=consider-using-join

if counter == len(outlines) - 1:
child_class = None
Expand Down
6 changes: 3 additions & 3 deletions aiida/cmdline/commands/cmd_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def create(
}

if AIIDA_LOGGER.level <= logging.REPORT: # pylint: disable=no-member
set_progress_bar_tqdm(leave=(AIIDA_LOGGER.level <= logging.INFO))
set_progress_bar_tqdm(leave=AIIDA_LOGGER.level <= logging.INFO)
else:
set_progress_reporter(None)

Expand Down Expand Up @@ -232,7 +232,7 @@ def migrate(input_file, output_file, force, in_place, version):
)

if AIIDA_LOGGER.level <= logging.REPORT: # pylint: disable=no-member
set_progress_bar_tqdm(leave=(AIIDA_LOGGER.level <= logging.INFO))
set_progress_bar_tqdm(leave=AIIDA_LOGGER.level <= logging.INFO)
else:
set_progress_reporter(None)

Expand Down Expand Up @@ -344,7 +344,7 @@ def import_archive(
from aiida.common.progress_reporter import set_progress_bar_tqdm, set_progress_reporter

if AIIDA_LOGGER.level <= logging.REPORT: # pylint: disable=no-member
set_progress_bar_tqdm(leave=(AIIDA_LOGGER.level <= logging.INFO))
set_progress_bar_tqdm(leave=AIIDA_LOGGER.level <= logging.INFO)
else:
set_progress_reporter(None)

Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/commands/cmd_calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def calcjob_cleanworkdir(calcjobs, past_days, older_than, computers, force, exit
echo.echo_critical('no calcjobs found with the given criteria')

if not force:
path_count = sum([len(paths) for computer, paths in path_mapping.items()])
path_count = sum(len(paths) for paths in path_mapping.values())
warning = f'Are you sure you want to clean the work directory of {path_count} calcjobs?'
click.confirm(warning, abort=True)

Expand Down
4 changes: 2 additions & 2 deletions aiida/cmdline/commands/cmd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def profile_list():
if not config.profiles:
echo.echo_warning('no profiles configured: run `verdi setup` to create one')
else:
sort = lambda profile: profile.name
highlight = lambda profile: profile.name == config.default_profile_name
sort = lambda profile: profile.name # pylint: disable=unnecessary-lambda-assignment
highlight = lambda profile: profile.name == config.default_profile_name # pylint: disable=unnecessary-lambda-assignment
echo.echo_formatted_list(config.profiles, ['name'], sort=sort, highlight=highlight)


Expand Down
12 changes: 6 additions & 6 deletions aiida/cmdline/commands/cmd_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
@contextlib.contextmanager
def update_environment(argv):
"""Context manager that temporarily replaces `sys.argv` with `argv` and adds current working dir to the path."""
try:
# Store a copy of the current path and argv as a backup variable so it can be restored later
_path = sys.path[:]
_argv = sys.argv[:]
# Store a copy of the current path and argv as a backup variable so it can be restored later
_path = sys.path[:]
_argv = sys.argv[:]

try:
# Add the current working directory to the path, such that local modules can be imported
sys.path.append(str(pathlib.Path.cwd().resolve()))
sys.argv = argv[:]
yield
finally:
# Restore old parameters when exiting from the context manager
sys.argv = _argv
sys.path = _path
sys.argv = _argv # pylint
sys.path = _path # pylint


def validate_entry_point_strings(_, __, value):
Expand Down
16 changes: 8 additions & 8 deletions aiida/cmdline/params/options/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def get_profile_attribute_default(attribute_tuple, ctx):
validate_profile_parameter(ctx)
except click.BadParameter:
return default
else:
try:
data = ctx.params['profile'].dictionary
for part in parts:
data = data[part]
return data
except KeyError:
return default

try:
data = ctx.params['profile'].dictionary
for part in parts:
data = data[part]
return data
except KeyError:
return default


def get_repository_uri_default(ctx):
Expand Down
1 change: 1 addition & 0 deletions aiida/cmdline/params/types/choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LazyChoice(click.ParamType):
name = 'choice'

def __init__(self, get_choices):
"""Construct a new instance."""
if not callable(get_choices):
raise TypeError(f"Must pass a callable, got '{get_choices}'")

Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/params/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def convert(self, value, param, ctx):

return get_option(value)

def shell_complete(self, ctx, param, incomplete): # pylint: disable=unused-argument,no-self-use
def shell_complete(self, ctx, param, incomplete): # pylint: disable=unused-argument
"""
Return possible completions based on an incomplete value
Expand Down
1 change: 1 addition & 0 deletions aiida/cmdline/params/types/multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MultipleValueParamType(click.ParamType):
"""

def __init__(self, param_type):
"""Construct a new instance."""
super().__init__()
self._param_type = param_type

Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/params/types/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_entry_point_from_string(self, entry_point_string):
group = matching_groups.pop()

else:
ValueError(f'invalid entry point string format: {entry_point_string}')
raise ValueError(f'invalid entry point string format: {entry_point_string}')

# If there is a factory for the entry point group, use that, otherwise use ``get_entry_point``
try:
Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/params/types/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def convert(self, value, param, ctx):

return profile

def shell_complete(self, ctx, param, incomplete): # pylint: disable=unused-argument,no-self-use
def shell_complete(self, ctx, param, incomplete): # pylint: disable=unused-argument
"""Return possible completions based on an incomplete value
:returns: list of tuples of valid entry points (matching incomplete) and a description
Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/params/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def convert(self, value, param, ctx):
return results[0]

@with_dbenv()
def shell_complete(self, ctx, param, incomplete): # pylint: disable=unused-argument,no-self-use
def shell_complete(self, ctx, param, incomplete): # pylint: disable=unused-argument
"""
Return possible completions based on an incomplete value
Expand Down
16 changes: 8 additions & 8 deletions aiida/cmdline/utils/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def echo(message: Any, fg: Optional[str] = None, bold: bool = False, nl: bool =
:param err: whether to log to stderr.
"""
message = click.style(message, fg=fg, bold=bold)
CMDLINE_LOGGER.report(message, extra=dict(nl=nl, err=err, prefix=False))
CMDLINE_LOGGER.report(message, extra={'nl': nl, 'err': err, 'prefix': False})


def echo_debug(message: str, bold: bool = False, nl: bool = True, err: bool = False, prefix: bool = True) -> None:
Expand All @@ -69,7 +69,7 @@ def echo_debug(message: str, bold: bool = False, nl: bool = True, err: bool = Fa
:param prefix: whether the message should be prefixed with a colored version of the log level.
"""
message = click.style(message, bold=bold)
CMDLINE_LOGGER.debug(message, extra=dict(nl=nl, err=err, prefix=prefix))
CMDLINE_LOGGER.debug(message, extra={'nl': nl, 'err': err, 'prefix': prefix})


def echo_info(message: str, bold: bool = False, nl: bool = True, err: bool = False, prefix: bool = True) -> None:
Expand All @@ -82,7 +82,7 @@ def echo_info(message: str, bold: bool = False, nl: bool = True, err: bool = Fal
:param prefix: whether the message should be prefixed with a colored version of the log level.
"""
message = click.style(message, bold=bold)
CMDLINE_LOGGER.info(message, extra=dict(nl=nl, err=err, prefix=prefix))
CMDLINE_LOGGER.info(message, extra={'nl': nl, 'err': err, 'prefix': prefix})


def echo_report(message: str, bold: bool = False, nl: bool = True, err: bool = False, prefix: bool = True) -> None:
Expand All @@ -95,7 +95,7 @@ def echo_report(message: str, bold: bool = False, nl: bool = True, err: bool = F
:param prefix: whether the message should be prefixed with a colored version of the log level.
"""
message = click.style(message, bold=bold)
CMDLINE_LOGGER.report(message, extra=dict(nl=nl, err=err, prefix=prefix))
CMDLINE_LOGGER.report(message, extra={'nl': nl, 'err': err, 'prefix': prefix})


def echo_success(message: str, bold: bool = False, nl: bool = True, err: bool = False, prefix: bool = True) -> None:
Expand All @@ -114,7 +114,7 @@ def echo_success(message: str, bold: bool = False, nl: bool = True, err: bool =
if prefix:
message = click.style('Success: ', bold=True, fg=COLORS['success']) + message

CMDLINE_LOGGER.report(message, extra=dict(nl=nl, err=err, prefix=False))
CMDLINE_LOGGER.report(message, extra={'nl': nl, 'err': err, 'prefix': False})


def echo_warning(message: str, bold: bool = False, nl: bool = True, err: bool = False, prefix: bool = True) -> None:
Expand All @@ -127,7 +127,7 @@ def echo_warning(message: str, bold: bool = False, nl: bool = True, err: bool =
:param prefix: whether the message should be prefixed with a colored version of the log level.
"""
message = click.style(message, bold=bold)
CMDLINE_LOGGER.warning(message, extra=dict(nl=nl, err=err, prefix=prefix))
CMDLINE_LOGGER.warning(message, extra={'nl': nl, 'err': err, 'prefix': prefix})


def echo_error(message: str, bold: bool = False, nl: bool = True, err: bool = True, prefix: bool = True) -> None:
Expand All @@ -140,7 +140,7 @@ def echo_error(message: str, bold: bool = False, nl: bool = True, err: bool = Tr
:param prefix: whether the message should be prefixed with a colored version of the log level.
"""
message = click.style(message, bold=bold)
CMDLINE_LOGGER.error(message, extra=dict(nl=nl, err=err, prefix=prefix))
CMDLINE_LOGGER.error(message, extra={'nl': nl, 'err': err, 'prefix': prefix})


def echo_critical(message: str, bold: bool = False, nl: bool = True, err: bool = True, prefix: bool = True) -> None:
Expand All @@ -156,7 +156,7 @@ def echo_critical(message: str, bold: bool = False, nl: bool = True, err: bool =
:param prefix: whether the message should be prefixed with a colored version of the log level.
"""
message = click.style(message, bold=bold)
CMDLINE_LOGGER.critical(message, extra=dict(nl=nl, err=err, prefix=prefix))
CMDLINE_LOGGER.critical(message, extra={'nl': nl, 'err': err, 'prefix': prefix})
sys.exit(ExitCode.CRITICAL)


Expand Down
3 changes: 2 additions & 1 deletion aiida/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def str_timedelta(dt, max_num_fields=3, short=False, negative_to_zero=False): #
if negative_to_zero:
s_tot = max(s_tot, 0)

negative = (s_tot < 0)
negative = s_tot < 0
s_tot = abs(s_tot)

negative_string = ' in the future' if negative else ' ago'
Expand Down Expand Up @@ -519,6 +519,7 @@ class Capturing:
# pylint: disable=attribute-defined-outside-init

def __init__(self, capture_stderr=False):
"""Construct a new instance."""
self.stdout_lines = []
super().__init__()

Expand Down
8 changes: 4 additions & 4 deletions aiida/engine/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class ObjectLoader(plumpy.loaders.DefaultObjectLoader):
"""Custom object loader for `aiida-core`."""

def load_object(self, identifier: str) -> Any: # pylint: disable=no-self-use
def load_object(self, identifier: str) -> Any:
"""Attempt to load the object identified by the given `identifier`.

.. note:: We override the `plumpy.DefaultObjectLoader` to be able to throw an `ImportError` instead of a
Expand Down Expand Up @@ -70,7 +70,7 @@ def get_object_loader() -> ObjectLoader:
class AiiDAPersister(plumpy.persistence.Persister):
"""Persister to take saved process instance states and persisting them to the database."""

def save_checkpoint(self, process: 'Process', tag: Optional[str] = None): # type: ignore[override] # pylint: disable=no-self-use
def save_checkpoint(self, process: 'Process', tag: Optional[str] = None): # type: ignore[override]
"""Persist a Process instance.

:param process: :class:`aiida.engine.Process`
Expand All @@ -95,7 +95,7 @@ def save_checkpoint(self, process: 'Process', tag: Optional[str] = None): # typ

return bundle

def load_checkpoint(self, pid: Hashable, tag: Optional[str] = None) -> plumpy.persistence.Bundle: # pylint: disable=no-self-use
def load_checkpoint(self, pid: Hashable, tag: Optional[str] = None) -> plumpy.persistence.Bundle:
"""Load a process from a persisted checkpoint by its process id.

:param pid: the process id of the :class:`plumpy.Process`
Expand Down Expand Up @@ -140,7 +140,7 @@ def get_process_checkpoints(self, pid: Hashable):
:return: list of PersistedCheckpoint tuples with element containing the process id and optional checkpoint tag.
"""

def delete_checkpoint(self, pid: Hashable, tag: Optional[str] = None) -> None: # pylint: disable=no-self-use,unused-argument
def delete_checkpoint(self, pid: Hashable, tag: Optional[str] = None) -> None: # pylint: disable=unused-argument
"""Delete a persisted process checkpoint, where no error will be raised if the checkpoint does not exist.

:param pid: the process id of the :class:`plumpy.Process`
Expand Down
4 changes: 2 additions & 2 deletions aiida/engine/processes/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ def _update(self, *args, **kwds):
if isinstance(value, Mapping):
self[key].update(value)
else:
self.__setattr__(key, value)
self.__setattr__(key, value) # pylint: disable=unnecessary-dunder-call

for key, value in kwds.items():
if isinstance(value, Mapping):
self[key].update(value)
else:
self.__setattr__(key, value)
self.__setattr__(key, value) # pylint: disable=unnecessary-dunder-call

def _inputs(self, prune: bool = False) -> dict:
"""Return the entire mapping of inputs specified for this builder.
Expand Down
1 change: 1 addition & 0 deletions aiida/engine/processes/calcjobs/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class CalcJobMonitors:
"""

def __init__(self, monitors: dict[str, Dict]):
"""Construct a new instance."""
type_check(monitors, dict)

if any(not isinstance(monitor, Dict) for monitor in monitors.values()):
Expand Down
2 changes: 1 addition & 1 deletion aiida/engine/processes/calcjobs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def do_upload():
)
except PreSubmitException:
raise
except (plumpy.futures.CancelledError, plumpy.process_states.Interruption):
except (plumpy.futures.CancelledError, plumpy.process_states.Interruption): # pylint: disable=try-except-raise
raise
except Exception as exception:
logger.warning(f'uploading CalcJob<{node.pk}> failed')
Expand Down
4 changes: 2 additions & 2 deletions aiida/engine/processes/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

LOGGER = logging.getLogger(__name__)

FunctionType = t.TypeVar('FunctionType', bound=t.Callable[..., t.Any])
FunctionType = t.TypeVar('FunctionType', bound=t.Callable[..., t.Any]) # pylint: disable=invalid-name


def calcfunction(function: FunctionType) -> FunctionType:
Expand Down Expand Up @@ -360,7 +360,7 @@ def _define(cls, spec): # pylint: disable=unused-argument
default is not None and default != UNSPECIFIED and not isinstance(default, Data) and
not callable(default)
):
indirect_default = lambda value=default: to_aiida_type(value)
indirect_default = lambda value=default: to_aiida_type(value) # pylint: disable=unnecessary-lambda-assignment
else:
indirect_default = default

Expand Down
7 changes: 3 additions & 4 deletions aiida/engine/processes/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def _create_and_setup_db_record(self) -> Union[int, UUID]:
return UUID(self.node.uuid)

@override
def encode_input_args(self, inputs: Dict[str, Any]) -> str: # pylint: disable=no-self-use
def encode_input_args(self, inputs: Dict[str, Any]) -> str:
"""
Encode input arguments such that they may be saved in a Bundle

Expand All @@ -645,7 +645,7 @@ def encode_input_args(self, inputs: Dict[str, Any]) -> str: # pylint: disable=n
return serialize.serialize(inputs)

@override
def decode_input_args(self, encoded: str) -> Dict[str, Any]: # pylint: disable=no-self-use
def decode_input_args(self, encoded: str) -> Dict[str, Any]:
"""
Decode saved input arguments as they came from the saved instance state Bundle

Expand Down Expand Up @@ -809,8 +809,7 @@ def _filter_serializable_metadata(
clean_value(port_value)
except exceptions.ValidationError:
return None
else:
return port_value
return port_value

result = {}

Expand Down
Loading

0 comments on commit 3976344

Please sign in to comment.