From 98e2bf275c70c29f88f092460219b788e9a26c16 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Wed, 12 Feb 2025 09:18:50 +0100 Subject: [PATCH] Work around ruff bug (?) UP006 Use `tuple` instead of `Tuple` for type annotation UP033 Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` UP035 `typing.Tuple` is deprecated, use `tuple` instead UP036 Version block is outdated for minimum Python version The minimum Python version is Python 3.8. From pyproject.toml: requires-python = ">=3.8" Yet, ruff somehow thinks the target is Python 3.9. --- backend/src/hatchling/builders/wheel.py | 4 ++-- .../src/hatchling/version/scheme/standard.py | 4 ++-- src/hatch/project/frontend/core.py | 18 +++++++++--------- src/hatch/utils/platform.py | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/src/hatchling/builders/wheel.py b/backend/src/hatchling/builders/wheel.py index d8ee57b90..ff43174f8 100644 --- a/backend/src/hatchling/builders/wheel.py +++ b/backend/src/hatchling/builders/wheel.py @@ -9,7 +9,7 @@ import zipfile from functools import cached_property from io import StringIO -from typing import TYPE_CHECKING, Any, Callable, NamedTuple, Tuple, cast +from typing import TYPE_CHECKING, Any, Callable, NamedTuple, Tuple, cast # noqa: UP035 from hatchling.__about__ import __version__ from hatchling.builders.config import BuilderConfig @@ -35,7 +35,7 @@ from hatchling.builders.plugin.interface import IncludedFile -TIME_TUPLE = Tuple[int, int, int, int, int, int] +TIME_TUPLE = Tuple[int, int, int, int, int, int] # noqa: UP006 class FileSelectionOptions(NamedTuple): diff --git a/backend/src/hatchling/version/scheme/standard.py b/backend/src/hatchling/version/scheme/standard.py index 5c3caebba..5c7fe209e 100644 --- a/backend/src/hatchling/version/scheme/standard.py +++ b/backend/src/hatchling/version/scheme/standard.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Tuple, cast +from typing import TYPE_CHECKING, Any, Tuple, cast # noqa: UP035 from hatchling.version.scheme.plugin.interface import VersionSchemeInterface @@ -95,4 +95,4 @@ def update_release(original_version: Version, new_release_parts: list[int]) -> t def parse_letter_version(*args: Any, **kwargs: Any) -> tuple[str, int]: from packaging.version import _parse_letter_version # noqa: PLC2701 - return cast(Tuple[str, int], _parse_letter_version(*args, **kwargs)) + return cast(Tuple[str, int], _parse_letter_version(*args, **kwargs)) # noqa: UP006 diff --git a/src/hatch/project/frontend/core.py b/src/hatch/project/frontend/core.py index 702923731..9487e3165 100644 --- a/src/hatch/project/frontend/core.py +++ b/src/hatch/project/frontend/core.py @@ -295,30 +295,30 @@ def get_core_metadata(self, *, output_dir: str, project_root: str) -> str: ) -if sys.version_info[:2] >= (3, 9): +if sys.version_info[:2] >= (3, 9): # noqa: UP036 - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def hook_caller_script() -> str: from importlib.resources import files script = files('pyproject_hooks._in_process') / '_in_process.py' return script.read_text(encoding='utf-8') - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def runner_script() -> str: from importlib.resources import files script = files('hatch.project.frontend.scripts') / 'standard.py' return script.read_text(encoding='utf-8') - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def hatch_build_deps_script() -> str: from importlib.resources import files script = files('hatch.project.frontend.scripts') / 'build_deps.py' return script.read_text(encoding='utf-8') - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def hatch_core_metadata_script() -> str: from importlib.resources import files @@ -327,25 +327,25 @@ def hatch_core_metadata_script() -> str: else: - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def hook_caller_script() -> str: from importlib.resources import read_text return read_text('pyproject_hooks._in_process', '_in_process.py') - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def runner_script() -> str: from importlib.resources import read_text return read_text('hatch.project.frontend.scripts', 'standard.py') - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def hatch_build_deps_script() -> str: from importlib.resources import read_text return read_text('hatch.project.frontend.scripts', 'build_deps.py') - @lru_cache(maxsize=None) + @lru_cache(maxsize=None) # noqa: UP033 def hatch_core_metadata_script() -> str: from importlib.resources import read_text diff --git a/src/hatch/utils/platform.py b/src/hatch/utils/platform.py index 21965835c..a3ef8042a 100644 --- a/src/hatch/utils/platform.py +++ b/src/hatch/utils/platform.py @@ -14,7 +14,7 @@ from hatch.utils.fs import Path -@lru_cache(maxsize=None) +@lru_cache(maxsize=None) # noqa: UP033 def get_platform_name() -> str: import platform