From 41fbf94162c9e4939db80b05b6cee48fceb802e4 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Wed, 15 Jan 2025 19:10:40 +0100 Subject: [PATCH] Apply ruff/pyupgrade rule UP036 UP036 Version block is outdated for minimum Python version --- src/hatch/project/frontend/core.py | 69 +++++++++--------------------- 1 file changed, 20 insertions(+), 49 deletions(-) diff --git a/src/hatch/project/frontend/core.py b/src/hatch/project/frontend/core.py index de66ff988..26a0ef47d 100644 --- a/src/hatch/project/frontend/core.py +++ b/src/hatch/project/frontend/core.py @@ -1,7 +1,6 @@ from __future__ import annotations import json -import sys from functools import cache from typing import TYPE_CHECKING, Any, Literal @@ -295,58 +294,30 @@ def get_core_metadata(self, *, output_dir: str, project_root: str) -> str: ) -if sys.version_info[:2] >= (3, 9): +@cache +def hook_caller_script() -> str: + from importlib.resources import files - @cache - 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') - script = files('pyproject_hooks._in_process') / '_in_process.py' - return script.read_text(encoding='utf-8') +@cache +def runner_script() -> str: + from importlib.resources import files - @cache - def runner_script() -> str: - from importlib.resources import files + script = files('hatch.project.frontend.scripts') / 'standard.py' + return script.read_text(encoding='utf-8') - script = files('hatch.project.frontend.scripts') / 'standard.py' - return script.read_text(encoding='utf-8') +@cache +def hatch_build_deps_script() -> str: + from importlib.resources import files - @cache - 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') - script = files('hatch.project.frontend.scripts') / 'build_deps.py' - return script.read_text(encoding='utf-8') +@cache +def hatch_core_metadata_script() -> str: + from importlib.resources import files - @cache - def hatch_core_metadata_script() -> str: - from importlib.resources import files - - script = files('hatch.project.frontend.scripts') / 'core_metadata.py' - return script.read_text(encoding='utf-8') - -else: - - @cache - def hook_caller_script() -> str: - from importlib.resources import read_text - - return read_text('pyproject_hooks._in_process', '_in_process.py') - - @cache - def runner_script() -> str: - from importlib.resources import read_text - - return read_text('hatch.project.frontend.scripts', 'standard.py') - - @cache - def hatch_build_deps_script() -> str: - from importlib.resources import read_text - - return read_text('hatch.project.frontend.scripts', 'build_deps.py') - - @cache - def hatch_core_metadata_script() -> str: - from importlib.resources import read_text - - return read_text('hatch.project.frontend.scripts', 'core_metadata.py') + script = files('hatch.project.frontend.scripts') / 'core_metadata.py' + return script.read_text(encoding='utf-8')