From 1f491233f2a81f0e8809a6094d7f0db0eb478ee9 Mon Sep 17 00:00:00 2001 From: Ali Date: Wed, 31 Jul 2024 09:58:15 +0200 Subject: [PATCH] dependencies: pre-commit formatting --- .pre-commit-config.yaml | 14 +++++++------- aiida_firecrest/scheduler.py | 1 + aiida_firecrest/transport.py | 15 +++++++-------- aiida_firecrest/utils.py | 2 +- conftest.py | 1 + firecrest_demo.py | 1 + tests/test_calculation.py | 1 + 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b20d7ff..92adb3f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-json - id: check-yaml @@ -16,28 +16,28 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 + rev: v3.16.0 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.4.2 hooks: - id: black - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.275 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.0 hooks: - id: ruff - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.10.1 hooks: - id: mypy files: ^(aiida_firecrest/.*py)$ diff --git a/aiida_firecrest/scheduler.py b/aiida_firecrest/scheduler.py index e18158e..553a9a9 100644 --- a/aiida_firecrest/scheduler.py +++ b/aiida_firecrest/scheduler.py @@ -1,4 +1,5 @@ """Scheduler interface.""" + from __future__ import annotations import datetime diff --git a/aiida_firecrest/transport.py b/aiida_firecrest/transport.py index 31a6743..6a2780b 100644 --- a/aiida_firecrest/transport.py +++ b/aiida_firecrest/transport.py @@ -1,4 +1,5 @@ """Transport interface.""" + from __future__ import annotations from contextlib import suppress @@ -27,7 +28,9 @@ class ValidAuthOption(TypedDict, total=False): switch: bool # whether the option is a boolean flag type: type[Any] | ParamType default: Any - non_interactive_default: bool # whether option should provide a default in non-interactive mode + non_interactive_default: ( + bool # whether option should provide a default in non-interactive mode + ) prompt: str # for interactive CLI help: str callback: Callable[..., Any] # for validation @@ -427,7 +430,7 @@ def get_description(cls) -> str: [f" {k}: {v.get('help', '')}" for k, v in cls.auth_options.items()] ) - def open(self) -> None: # noqa: A003 + def open(self) -> None: """Open the transport. This is a no-op for the REST-API, as there is no connection to open. """ @@ -977,14 +980,10 @@ def payoff(self, path: str | FcPath | Path) -> bool: if self.payoff_override is not None: return bool(self.payoff_override) - if ( + return ( isinstance(path, FcPath) and len(self.listdir(str(path), recursive=True)) > 3 - ): - return True - if isinstance(path, Path) and len(os.listdir(path)) > 3: - return True - return False + ) or (isinstance(path, Path) and len(os.listdir(path)) > 3) def _puttreetar( self, diff --git a/aiida_firecrest/utils.py b/aiida_firecrest/utils.py index cee4bcb..0fec760 100644 --- a/aiida_firecrest/utils.py +++ b/aiida_firecrest/utils.py @@ -65,7 +65,7 @@ def convert_header_exceptions( yield except HeaderException as exc: for header in exc.responses[-1].headers: - c = converters.get(header, None) + c = converters.get(header) if c is not None: raise c(data) from exc raise diff --git a/conftest.py b/conftest.py index 1b417a3..3f71d60 100644 --- a/conftest.py +++ b/conftest.py @@ -1,4 +1,5 @@ """Pytest configuration that must be at the root level.""" + pytest_plugins = ["aiida.manage.tests.pytest_fixtures"] diff --git a/firecrest_demo.py b/firecrest_demo.py index 21c5e30..3bf2e80 100644 --- a/firecrest_demo.py +++ b/firecrest_demo.py @@ -6,6 +6,7 @@ This code is not tested, with anything above version "v1.13.0" of FirecREST, and it's not maintained. See also https://github.com/aiidateam/aiida-firecrest/issues/47 """ + from __future__ import annotations from argparse import ArgumentParser diff --git a/tests/test_calculation.py b/tests/test_calculation.py index fb34ae6..a71e924 100644 --- a/tests/test_calculation.py +++ b/tests/test_calculation.py @@ -1,4 +1,5 @@ """Test for running calculations on a FireCREST computer.""" + from pathlib import Path from aiida import common, engine, manage, orm