From f40815af7274d37d7d8b66051c33ba335b97e953 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Wed, 3 Jul 2024 17:57:47 +0100 Subject: [PATCH] Update project for newer versions of black and ruff --- dwasfile.py | 1 + pyproject.toml | 4 +++- src/dwas/__init__.py | 1 + src/dwas/_logging.py | 8 +++++--- src/dwas/_pipeline.py | 16 ++++++++-------- src/dwas/_steps/parametrize.py | 6 ++---- src/dwas/_subproc.py | 6 +++--- tests/predefined/test_package.py | 2 +- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dwasfile.py b/dwasfile.py index adf4285..a32be78 100644 --- a/dwasfile.py +++ b/dwasfile.py @@ -1,6 +1,7 @@ """ Contains the dwas configuration for this project. """ + from pathlib import Path import dwas diff --git a/pyproject.toml b/pyproject.toml index 92570b5..09dc0c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -135,6 +135,8 @@ disable = [ # Ruff [tool.ruff] target-version = "py38" + +[tool.ruff.lint] select = ["ALL"] ignore = [ ## @@ -183,7 +185,7 @@ ignore = [ flake8-pytest-style.parametrize-values-type = "tuple" flake8-pytest-style.parametrize-values-row-type = "tuple" flake8-pytest-style.fixture-parentheses = false -lint.isort.known-first-party = ["dwas"] +isort.known-first-party = ["dwas"] [tool.ruff.lint.per-file-ignores] "docs/*" = ["D"] diff --git a/src/dwas/__init__.py b/src/dwas/__init__.py index 329c8bd..6c33da9 100644 --- a/src/dwas/__init__.py +++ b/src/dwas/__init__.py @@ -9,6 +9,7 @@ While ``dwas`` is not at version 1.0.0, it does not guarantee API stability. """ + from ._config import Config from ._exceptions import BaseDwasException from ._steps import ( diff --git a/src/dwas/_logging.py b/src/dwas/_logging.py index 9e56993..48b413b 100644 --- a/src/dwas/_logging.py +++ b/src/dwas/_logging.py @@ -20,7 +20,7 @@ class ColorFormatter(logging.Formatter): { logging.DEBUG: Fore.CYAN, logging.INFO: "", - logging.WARN: Fore.YELLOW, + logging.WARNING: Fore.YELLOW, logging.ERROR: Fore.RED + Style.BRIGHT, logging.FATAL: Back.RED + Fore.WHITE + Style.BRIGHT, } @@ -32,8 +32,10 @@ def formatMessage(self, record: logging.LogRecord) -> str: def formatException( self, - ei: tuple[type[BaseException], BaseException, TracebackType | None] - | tuple[None, None, None], + ei: ( + tuple[type[BaseException], BaseException, TracebackType | None] + | tuple[None, None, None] + ), ) -> str: output = super().formatException(ei) return f"{Fore.CYAN}\ndwas > " + "\ndwas > ".join(output.splitlines()) diff --git a/src/dwas/_pipeline.py b/src/dwas/_pipeline.py index ad46c93..1ebe2ba 100644 --- a/src/dwas/_pipeline.py +++ b/src/dwas/_pipeline.py @@ -228,9 +228,9 @@ def compute_replacement(requirements: list[str]) -> list[str]: replacements.append(requirement) else: if requirement not in except_replacements: - except_replacements[ - requirement - ] = compute_replacement(graph[requirement]) + except_replacements[requirement] = ( + compute_replacement(graph[requirement]) + ) replacements.extend(except_replacements[requirement]) return replacements @@ -264,10 +264,10 @@ def compute_only_replacement( replacements = [] for requirement in requirements: if requirement not in only_replacements: - only_replacements[ - requirement - ] = compute_only_replacement( - requirement, graph[requirement] + only_replacements[requirement] = ( + compute_only_replacement( + requirement, graph[requirement] + ) ) replacements.extend(only_replacements[requirement]) @@ -665,7 +665,7 @@ def _compute_slowest_chains( total_time_per_step: dict[str, tuple[list[str], timedelta]] = {} def compute_chain(step: str) -> tuple[list[str], timedelta]: - precomputed_result = total_time_per_step.get(step, None) + precomputed_result = total_time_per_step.get(step) if precomputed_result is not None: return precomputed_result diff --git a/src/dwas/_steps/parametrize.py b/src/dwas/_steps/parametrize.py index e89ef0d..7af7581 100644 --- a/src/dwas/_steps/parametrize.py +++ b/src/dwas/_steps/parametrize.py @@ -90,8 +90,7 @@ def parametrize( arg_names: str, args_values: Sequence[Any], ids: Sequence[str | None] | None = None, -) -> Callable[[T], T]: - ... +) -> Callable[[T], T]: ... @overload @@ -99,8 +98,7 @@ def parametrize( arg_names: Sequence[str], args_values: Sequence[Sequence[Any]], ids: Sequence[str | None] | None = None, -) -> Callable[[T], T]: - ... +) -> Callable[[T], T]: ... def parametrize( diff --git a/src/dwas/_subproc.py b/src/dwas/_subproc.py index 42f9668..ee7c789 100644 --- a/src/dwas/_subproc.py +++ b/src/dwas/_subproc.py @@ -114,9 +114,9 @@ def _run() -> subprocess.CompletedProcess[None]: stdout_reader.join() stderr_reader.join() - ret: subprocess.CompletedProcess[ - None - ] = subprocess.CompletedProcess(command, proc.returncode) + ret: subprocess.CompletedProcess[None] = ( + subprocess.CompletedProcess(command, proc.returncode) + ) self._remove(proc) ret.check_returncode() return ret diff --git a/tests/predefined/test_package.py b/tests/predefined/test_package.py index b82e7fa..c421a3e 100644 --- a/tests/predefined/test_package.py +++ b/tests/predefined/test_package.py @@ -17,7 +17,7 @@ def test_exposes_sdists_and_wheels(self, cache_path): cli(cache_path=cache_path, steps=["output_artifacts"]) artifacts = json.loads(Path("artifacts.json").read_text("utf-8")) assert list(artifacts.keys()) == ["sdists", "wheels"] - assert Path(artifacts["sdists"][0]).name == "test-package-0.0.0.tar.gz" + assert Path(artifacts["sdists"][0]).name == "test_package-0.0.0.tar.gz" assert ( Path(artifacts["wheels"][0]).name == "test_package-0.0.0-py3-none-any.whl"