Skip to content

Commit

Permalink
Work around ruff bug (?)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DimitriPapadopoulos committed Feb 12, 2025
1 parent b82abc0 commit 98e2bf2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions backend/src/hatchling/builders/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions backend/src/hatchling/version/scheme/standard.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
18 changes: 9 additions & 9 deletions src/hatch/project/frontend/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/hatch/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 98e2bf2

Please sign in to comment.