Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ruff to v0.8 #6634

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
20 changes: 10 additions & 10 deletions .github/system_tests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
import tempfile
import time

from aiida.common import StashMode, exceptions
from aiida.engine import run, submit
from aiida.engine.daemon.client import get_daemon_client
from aiida.engine.persistence import ObjectLoader
from aiida.engine.processes import CalcJob, Process
from aiida.manage.caching import enable_caching
from aiida.orm import CalcJobNode, Dict, Int, List, Str, load_code, load_node
from aiida.orm.nodes.caching import NodeCaching
from aiida.plugins import CalculationFactory, WorkflowFactory
from aiida.workflows.arithmetic.add_multiply import add, add_multiply
from workchains import (
ArithmeticAddBaseWorkChain,
CalcFunctionRunnerWorkChain,
Expand All @@ -39,6 +29,16 @@
WorkFunctionRunnerWorkChain,
)

from aiida.common import StashMode, exceptions
from aiida.engine import run, submit
from aiida.engine.daemon.client import get_daemon_client
from aiida.engine.persistence import ObjectLoader
from aiida.engine.processes import CalcJob, Process
from aiida.manage.caching import enable_caching
from aiida.orm import CalcJobNode, Dict, Int, List, Str, load_code, load_node
from aiida.orm.nodes.caching import NodeCaching
from aiida.plugins import CalculationFactory, WorkflowFactory
from aiida.workflows.arithmetic.add_multiply import add, add_multiply
from tests.utils.memory import get_instances

CODENAME_ADD = 'add@localhost'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
AIIDA_WARN_v3: 1
# Python 3.12 has a performance regression when running with code coverage
# so run code coverage only for python 3.9.
run: pytest -v tests -m 'not nightly' ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}
run: pytest tests -m 'not nightly' ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}

- name: Upload coverage report
if: matrix.python-version == 3.9 && github.repository == 'aiidateam/aiida-core'
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 1

jobs:

validate-dependency-specification:
Expand Down Expand Up @@ -229,7 +232,7 @@ jobs:
env:
AIIDA_TEST_PROFILE: test_aiida
AIIDA_WARN_v3: 1
run: pytest --verbose tests -m 'not nightly'
run: pytest tests -m 'not nightly'

- name: Freeze test environment
run: pip freeze | sed '1d' | tee requirements-py-${{ matrix.python-version }}.txt
Expand Down
1 change: 1 addition & 0 deletions .molecule/default/files/polish/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import time

import click

from aiida.cmdline.params import options, types
from aiida.cmdline.utils import decorators

Expand Down
8 changes: 1 addition & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,10 @@ repos:
args: [--line-length=120, --fail-on-change]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.8.0
hooks:
- id: ruff-format
exclude: &exclude_ruff >
(?x)^(
docs/source/topics/processes/include/snippets/functions/parse_docstring_expose_ipython.py|
docs/source/topics/processes/include/snippets/functions/signature_plain_python_call_illegal.py|
)$
- id: ruff
exclude: *exclude_ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Script to benchmark the performance of the AiiDA workflow engine on a given installation."""

import click

from aiida.cmdline.params import options
from aiida.cmdline.utils import decorators, echo

Expand Down
3 changes: 2 additions & 1 deletion docs/source/internals/includes/snippets/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
import click
from flask_restful import Resource

from aiida import load_profile
from aiida.restapi import common
from aiida.restapi.api import AiidaApi, App
from aiida.restapi.run_api import run_api
from flask_restful import Resource


class NewResource(Resource):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env runaiida
from aiida.engine import run
from serialize_workchain import SerializeWorkChain

from aiida.engine import run

if __name__ == '__main__':
print(run(SerializeWorkChain, a=1, b=1.2, c=True))
# Result: {'a': 1, 'b': 1.2, 'c': True}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aiida.engine import ToContext, WorkChain
from child import ChildWorkChain

from aiida.engine import ToContext, WorkChain


class ComplexParentWorkChain(WorkChain):
@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env runaiida

from complex_parent import ComplexParentWorkChain

from aiida.engine import run
from aiida.orm import Bool, Float, Int
from complex_parent import ComplexParentWorkChain

if __name__ == '__main__':
result = run(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env runaiida

from simple_parent import SimpleParentWorkChain

from aiida.engine import run
from aiida.orm import Bool, Float, Int
from simple_parent import SimpleParentWorkChain

if __name__ == '__main__':
result = run(SimpleParentWorkChain, a=Int(1), b=Float(1.2), c=Bool(True))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aiida.engine import ToContext, WorkChain
from child import ChildWorkChain

from aiida.engine import ToContext, WorkChain


class SimpleParentWorkChain(WorkChain):
@classmethod
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ testpaths = [
xfail_strict = true

[tool.ruff]
exclude = [
'docs/source/topics/processes/include/snippets/functions/parse_docstring_expose_ipython.py',
'docs/source/topics/processes/include/snippets/functions/signature_plain_python_call_illegal.py'
]
line-length = 120

[tool.ruff.format]
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/brokers/rabbitmq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if t.TYPE_CHECKING:
import requests

__all__ = ('RabbitmqManagementClient', 'ManagementApiConnectionError')
__all__ = ('ManagementApiConnectionError', 'RabbitmqManagementClient')


class ManagementApiConnectionError(AiidaException):
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/brokers/rabbitmq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from . import defaults

__all__ = ('get_rmq_url', 'get_launch_queue_name', 'get_message_exchange_name', 'get_task_exchange_name')
__all__ = ('get_launch_queue_name', 'get_message_exchange_name', 'get_rmq_url', 'get_task_exchange_name')


def get_rmq_url(protocol=None, username=None, password=None, host=None, port=None, virtual_host=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/groups/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def list_options(self, entry_point: str) -> list:
# ``typing.Union[str, None].__args__`` will return the tuple ``(str, NoneType)``. So to get the real type,
# we simply remove all ``NoneType`` and the remaining type should be the type of the option.
if hasattr(field_info.annotation, '__args__'):
args = list(filter(lambda e: e != type(None), field_info.annotation.__args__))
args = list(filter(lambda e: e is not type(None), field_info.annotation.__args__))
# Click parameters only support specifying a single type, so we default to the first one even if the
# pydantic model defines multiple.
field_type = args[0]
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/params/arguments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
'NODE',
'NODES',
'OUTPUT_FILE',
'OverridableArgument',
'PROCESS',
'PROCESSES',
'PROFILE',
'PROFILES',
'USER',
'WORKFLOW',
'WORKFLOWS',
'OverridableArgument',
)

# fmt: on
16 changes: 8 additions & 8 deletions src/aiida/cmdline/params/arguments/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
from .overridable import OverridableArgument

__all__ = (
'PROFILE',
'PROFILES',
'CALCULATION',
'CALCULATIONS',
'CODE',
'CODES',
'COMPUTER',
'COMPUTERS',
'DATUM',
'CONFIG_OPTION',
'DATA',
'DATUM',
'GROUP',
'GROUPS',
'INPUT_FILE',
'LABEL',
'NODE',
'NODES',
'OUTPUT_FILE',
'PROCESS',
'PROCESSES',
'PROFILE',
'PROFILES',
'USER',
'WORKFLOW',
'WORKFLOWS',
'INPUT_FILE',
'OUTPUT_FILE',
'LABEL',
'USER',
'CONFIG_OPTION',
)


Expand Down
8 changes: 4 additions & 4 deletions src/aiida/cmdline/params/options/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
'COMPUTER',
'COMPUTERS',
'CONFIG_FILE',
'CallableDefaultOption',
'ConfigFileOption',
'DATA',
'DATUM',
'DB_BACKEND',
Expand Down Expand Up @@ -69,14 +67,12 @@
'INPUT_PLUGIN',
'LABEL',
'LIMIT',
'MultipleValueOption',
'NODE',
'NODES',
'NON_INTERACTIVE',
'OLDER_THAN',
'ORDER_BY',
'ORDER_DIRECTION',
'OverridableOption',
'PAST_DAYS',
'PAUSED',
'PORT',
Expand Down Expand Up @@ -108,6 +104,10 @@
'WAIT',
'WITH_ELEMENTS',
'WITH_ELEMENTS_EXCLUSIVE',
'CallableDefaultOption',
'ConfigFileOption',
'MultipleValueOption',
'OverridableOption',
'active_process_states',
'graph_traversal_rules',
'valid_calc_job_states',
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/params/options/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
'ORDER_BY',
'ORDER_DIRECTION',
'OVERWRITE',
'PATH',
'PAST_DAYS',
'PATH',
'PAUSED',
'PORT',
'PREPEND_TEXT',
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 @@ -14,7 +14,7 @@
from ...utils import decorators
from .identifier import IdentifierParamType

__all__ = ('ComputerParamType', 'ShebangParamType', 'MpirunCommandParamType')
__all__ = ('ComputerParamType', 'MpirunCommandParamType', 'ShebangParamType')


class ComputerParamType(IdentifierParamType):
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/params/types/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from click.types import StringParamType

__all__ = ('EmailType', 'EntryPointType', 'HostnameType', 'NonEmptyStringParamType', 'LabelStringType')
__all__ = ('EmailType', 'EntryPointType', 'HostnameType', 'LabelStringType', 'NonEmptyStringParamType')


class NonEmptyStringParamType(StringParamType):
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/cmdline/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

DAEMON_NOT_RUNNING_DEFAULT_MESSAGE = 'daemon is not running'

__all__ = ('with_dbenv', 'dbenv', 'only_if_daemon_running')
__all__ = ('dbenv', 'only_if_daemon_running', 'with_dbenv')


@decorator
Expand Down
10 changes: 5 additions & 5 deletions src/aiida/cmdline/utils/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
CMDLINE_LOGGER = logging.getLogger('verdi')

__all__ = (
'echo_report',
'echo_critical',
'echo_dictionary',
'echo_error',
'echo_info',
'echo_report',
'echo_success',
'echo_warning',
'echo_error',
'echo_critical',
'echo_tabulate',
'echo_dictionary',
'echo_warning',
)


Expand Down
2 changes: 1 addition & 1 deletion src/aiida/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

__all__ = (
'AIIDA_LOGGER',
'TQDM_BAR_FORMAT',
'AiidaException',
'AttributeDict',
'CalcInfo',
Expand Down Expand Up @@ -74,7 +75,6 @@
'StashMode',
'StorageMigrationError',
'StoringNotAllowed',
'TQDM_BAR_FORMAT',
'TestsNotAllowedError',
'TransportTaskException',
'UniquenessError',
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/common/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from .extendeddicts import DefaultFieldsAttributeDict

__all__ = ('StashMode', 'CalcJobState', 'CalcInfo', 'CodeInfo', 'CodeRunMode')
__all__ = ('CalcInfo', 'CalcJobState', 'CodeInfo', 'CodeRunMode', 'StashMode')


class StashMode(Enum):
Expand Down
Loading