From f008575c47212ed8a993c48f95d69cbe9b217442 Mon Sep 17 00:00:00 2001 From: finswimmer Date: Tue, 17 Sep 2024 06:16:12 +0200 Subject: [PATCH 1/5] feat: drop support for Python 3.8 --- .cirrus.yml | 4 --- .github/workflows/tests.yaml | 1 - poetry.lock | 35 ++----------------- pyproject.toml | 4 +-- src/poetry/console/commands/env/remove.py | 5 ++- src/poetry/console/commands/init.py | 5 ++- src/poetry/inspection/info.py | 6 ++-- src/poetry/mixology/version_solver.py | 3 +- src/poetry/packages/direct_origin.py | 2 +- src/poetry/packages/package_collection.py | 3 +- src/poetry/plugins/plugin_manager.py | 2 +- src/poetry/puzzle/solver.py | 4 +-- src/poetry/repositories/http_repository.py | 3 +- src/poetry/repositories/link_sources/base.py | 5 ++- src/poetry/utils/_compat.py | 22 ------------ src/poetry/utils/dependency_specification.py | 4 +-- src/poetry/utils/env/base_env.py | 4 +-- src/poetry/utils/isolated_build.py | 4 +-- tests/conftest.py | 2 +- tests/console/commands/test_check.py | 2 +- tests/helpers.py | 2 +- tests/inspection/test_info.py | 2 +- tests/integration/test_utils_vcs_git.py | 3 +- .../masonry/builders/test_editable_builder.py | 3 +- tests/packages/test_locker.py | 12 ++++--- .../fixtures/pypi.org/generate.py | 26 +++++++++----- tests/repositories/fixtures/python_hosted.py | 2 +- .../repositories/test_installed_repository.py | 3 +- tests/types.py | 10 +++--- tests/utils/env/test_env.py | 2 +- 30 files changed, 64 insertions(+), 121 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index a1ada2d62b6..12ff2a5bdca 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,10 +8,6 @@ tests_task: env: matrix: - - PYTHON: python3.8 - PYTHON_VERSION: 3.8 - PYTHON_PACKAGE: python38 - SQLITE_PACKAGE: py38-sqlite3 - PYTHON: python3.9 PYTHON_VERSION: 3.9 PYTHON_PACKAGE: python39 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 51a4434c25e..aa1392ae989 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -124,7 +124,6 @@ jobs: - name: macOS aarch64 image: macos-14 python-version: - - "3.8" - "3.9" - "3.10" - "3.11" diff --git a/poetry.lock b/poetry.lock index 8bef0cfed76..2a2b4f22489 100644 --- a/poetry.lock +++ b/poetry.lock @@ -621,24 +621,6 @@ doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linke perf = ["ipython"] test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] -[[package]] -name = "importlib-resources" -version = "6.4.0" -description = "Read resources from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_resources-6.4.0-py3-none-any.whl", hash = "sha256:50d10f043df931902d4194ea07ec57960f66a80449ff867bfe782b4c486ba78c"}, - {file = "importlib_resources-6.4.0.tar.gz", hash = "sha256:cdb2b453b8046ca4e3798eb1d84f3cce1446a0e8e7b5ef4efb600f19fc398145"}, -] - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["jaraco.test (>=5.4)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] - [[package]] name = "iniconfig" version = "2.0.0" @@ -743,7 +725,6 @@ files = [ [package.dependencies] importlib-metadata = {version = ">=4.11.4", markers = "python_version < \"3.12\""} -importlib-resources = {version = "*", markers = "python_version < \"3.9\""} "jaraco.classes" = "*" "jaraco.context" = "*" "jaraco.functools" = "*" @@ -833,7 +814,6 @@ files = [ {file = "msgpack-1.0.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fbb160554e319f7b22ecf530a80a3ff496d38e8e07ae763b9e82fadfe96f273"}, {file = "msgpack-1.0.8-cp39-cp39-win32.whl", hash = "sha256:f9af38a89b6a5c04b7d18c492c8ccf2aee7048aff1ce8437c4683bb5a1df893d"}, {file = "msgpack-1.0.8-cp39-cp39-win_amd64.whl", hash = "sha256:ed59dd52075f8fc91da6053b12e8c89e37aa043f8986efd89e61fae69dc1b011"}, - {file = "msgpack-1.0.8-py3-none-any.whl", hash = "sha256:24f727df1e20b9876fa6e95f840a2a2651e34c0ad147676356f4bf5fbb0206ca"}, {file = "msgpack-1.0.8.tar.gz", hash = "sha256:95c02b0e27e706e48d0e5426d1710ca78e0f0628d6e89d5b5a5b91a5f12274f3"}, ] @@ -1215,7 +1195,6 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1223,16 +1202,8 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1249,7 +1220,6 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1257,7 +1227,6 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1630,5 +1599,5 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" -python-versions = "^3.8" -content-hash = "74b6f4dc98249bd138d4a45120c185f5df794354b880c1695aab8e197df8e87e" +python-versions = "^3.9" +content-hash = "46dbbe39c0a9dd1a2fcfb72dc37639b203729cfbf91b6e014c2238bd4fd02145" diff --git a/pyproject.toml b/pyproject.toml index 6b8ba209ff2..afd83be6d0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ Changelog = "https://python-poetry.org/history/" # Requirements [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" poetry-core = { git = "https://github.com/python-poetry/poetry-core.git", branch = "main" } build = "^1.2.1" @@ -104,7 +104,7 @@ extend-exclude = [ ] fix = true line-length = 88 -target-version = "py38" +target-version = "py39" [tool.ruff.lint] extend-select = [ diff --git a/src/poetry/console/commands/env/remove.py b/src/poetry/console/commands/env/remove.py index f19e9aa505f..a492959ebbe 100644 --- a/src/poetry/console/commands/env/remove.py +++ b/src/poetry/console/commands/env/remove.py @@ -7,7 +7,6 @@ from cleo.helpers import option from poetry.console.commands.command import Command -from poetry.utils._compat import is_relative_to if TYPE_CHECKING: @@ -55,8 +54,8 @@ def handle(self) -> int: self.line(f"Deleted virtualenv: {venv.path}") if remove_all_envs or is_in_project: for venv in manager.list(): - if not is_in_project or is_relative_to( - venv.path, self.poetry.pyproject_path.parent + if not is_in_project or venv.path.is_relative_to( + self.poetry.pyproject_path.parent ): manager.remove_venv(venv.path) self.line(f"Deleted virtualenv: {venv.path}") diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py index e7fbf13109f..b2cb367d7c1 100644 --- a/src/poetry/console/commands/init.py +++ b/src/poetry/console/commands/init.py @@ -1,12 +1,11 @@ from __future__ import annotations +from collections.abc import Mapping from contextlib import suppress from pathlib import Path from typing import TYPE_CHECKING from typing import Any from typing import ClassVar -from typing import Dict -from typing import Mapping from typing import Union from cleo.helpers import option @@ -27,7 +26,7 @@ from poetry.repositories import RepositoryPool -Requirements = Dict[str, Union[str, Mapping[str, Any]]] +Requirements = dict[str, Union[str, Mapping[str, Any]]] class InitCommand(Command): diff --git a/src/poetry/inspection/info.py b/src/poetry/inspection/info.py index e260818164d..6aae9bc5072 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -9,8 +9,6 @@ from pathlib import Path from typing import TYPE_CHECKING from typing import Any -from typing import Mapping -from typing import Sequence import pkginfo @@ -31,6 +29,8 @@ if TYPE_CHECKING: from collections.abc import Iterator + from collections.abc import Mapping + from collections.abc import Sequence from packaging.metadata import RawMetadata from packaging.utils import NormalizedName @@ -523,7 +523,7 @@ def from_path(cls, path: Path) -> PackageInfo: return cls.from_sdist(path=path) -@functools.lru_cache(maxsize=None) +@functools.cache def get_pep517_metadata(path: Path) -> PackageInfo: """ Helper method to use PEP-517 library to build and read package metadata. diff --git a/src/poetry/mixology/version_solver.py b/src/poetry/mixology/version_solver.py index 30b87087f60..45af85e68c0 100644 --- a/src/poetry/mixology/version_solver.py +++ b/src/poetry/mixology/version_solver.py @@ -6,7 +6,6 @@ from typing import TYPE_CHECKING from typing import Optional -from typing import Tuple from poetry.core.packages.dependency import Dependency @@ -32,7 +31,7 @@ _conflict = object() -DependencyCacheKey = Tuple[ +DependencyCacheKey = tuple[ str, Optional[str], Optional[str], Optional[str], Optional[str] ] diff --git a/src/poetry/packages/direct_origin.py b/src/poetry/packages/direct_origin.py index 561b7a4223e..af98ac2e4e1 100644 --- a/src/poetry/packages/direct_origin.py +++ b/src/poetry/packages/direct_origin.py @@ -22,7 +22,7 @@ from poetry.utils.cache import ArtifactCache -@functools.lru_cache(maxsize=None) +@functools.cache def _get_package_from_git( url: str, branch: str | None = None, diff --git a/src/poetry/packages/package_collection.py b/src/poetry/packages/package_collection.py index e08d9a31846..4457b506169 100644 --- a/src/poetry/packages/package_collection.py +++ b/src/poetry/packages/package_collection.py @@ -1,7 +1,6 @@ from __future__ import annotations from typing import TYPE_CHECKING -from typing import List from poetry.packages.dependency_package import DependencyPackage @@ -13,7 +12,7 @@ from poetry.core.packages.package import Package -class PackageCollection(List[DependencyPackage]): +class PackageCollection(list[DependencyPackage]): def __init__( self, dependency: Dependency, diff --git a/src/poetry/plugins/plugin_manager.py b/src/poetry/plugins/plugin_manager.py index 95ac8b0341d..042985da1bb 100644 --- a/src/poetry/plugins/plugin_manager.py +++ b/src/poetry/plugins/plugin_manager.py @@ -9,7 +9,6 @@ from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING -from typing import Sequence import tomlkit @@ -30,6 +29,7 @@ if TYPE_CHECKING: + from collections.abc import Sequence from typing import Any from cleo.io.io import IO diff --git a/src/poetry/puzzle/solver.py b/src/poetry/puzzle/solver.py index 0b6742217d8..bf080b32970 100644 --- a/src/poetry/puzzle/solver.py +++ b/src/poetry/puzzle/solver.py @@ -5,8 +5,6 @@ from collections import defaultdict from contextlib import contextmanager from typing import TYPE_CHECKING -from typing import FrozenSet -from typing import Tuple from poetry.mixology import resolve_version from poetry.mixology.failure import SolveFailureError @@ -195,7 +193,7 @@ def _solve(self) -> tuple[list[Package], list[int]]: return final_packages, depths -DFSNodeID = Tuple[str, FrozenSet[str], bool] +DFSNodeID = tuple[str, frozenset[str], bool] class DFSNode: diff --git a/src/poetry/repositories/http_repository.py b/src/poetry/repositories/http_repository.py index 581bd7eebb7..905668e66f0 100644 --- a/src/poetry/repositories/http_repository.py +++ b/src/poetry/repositories/http_repository.py @@ -8,7 +8,6 @@ from pathlib import Path from typing import TYPE_CHECKING from typing import Any -from typing import Iterator import requests import requests.adapters @@ -36,6 +35,8 @@ if TYPE_CHECKING: + from collections.abc import Iterator + from packaging.utils import NormalizedName from poetry.core.packages.utils.link import Link diff --git a/src/poetry/repositories/link_sources/base.py b/src/poetry/repositories/link_sources/base.py index 53bf073c523..12c211efe10 100644 --- a/src/poetry/repositories/link_sources/base.py +++ b/src/poetry/repositories/link_sources/base.py @@ -6,8 +6,6 @@ from functools import cached_property from typing import TYPE_CHECKING from typing import ClassVar -from typing import DefaultDict -from typing import List from poetry.core.constraints.version import Version from poetry.core.packages.package import Package @@ -18,12 +16,13 @@ if TYPE_CHECKING: + from collections import defaultdict from collections.abc import Iterator from packaging.utils import NormalizedName from poetry.core.packages.utils.link import Link - LinkCache = DefaultDict[NormalizedName, DefaultDict[Version, List[Link]]] + LinkCache = defaultdict[NormalizedName, defaultdict[Version, list[Link]]] logger = logging.getLogger(__name__) diff --git a/src/poetry/utils/_compat.py b/src/poetry/utils/_compat.py index 6781096ddaf..4b2a74eab19 100644 --- a/src/poetry/utils/_compat.py +++ b/src/poetry/utils/_compat.py @@ -4,11 +4,6 @@ import sys from contextlib import suppress -from typing import TYPE_CHECKING - - -if TYPE_CHECKING: - from pathlib import Path if sys.version_info < (3, 11): @@ -60,28 +55,11 @@ def getencoding() -> str: return locale.getencoding() -def is_relative_to(this: Path, other: Path) -> bool: - """ - Return whether `this` path is relative to the `other` path. This is compatibility wrapper around - `PurePath.is_relative_to()` method. This method was introduced only in Python 3.9. - - See: https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.is_relative_to - """ - if sys.version_info < (3, 9): - with suppress(ValueError): - this.relative_to(other) - return True - return False - - return this.is_relative_to(other) - - __all__ = [ "WINDOWS", "decode", "encode", "getencoding", - "is_relative_to", "metadata", "tomllib", ] diff --git a/src/poetry/utils/dependency_specification.py b/src/poetry/utils/dependency_specification.py index fc21fe5cf46..4071fbcd7b7 100644 --- a/src/poetry/utils/dependency_specification.py +++ b/src/poetry/utils/dependency_specification.py @@ -7,8 +7,6 @@ from pathlib import Path from typing import TYPE_CHECKING -from typing import Dict -from typing import List from typing import TypeVar from typing import Union from typing import cast @@ -26,7 +24,7 @@ from poetry.utils.env import Env -DependencySpec = Dict[str, Union[str, bool, Dict[str, Union[str, bool]], List[str]]] +DependencySpec = dict[str, Union[str, bool, dict[str, Union[str, bool]], list[str]]] BaseSpec = TypeVar("BaseSpec", DependencySpec, InlineTable) GIT_URL_SCHEMES = {"git+http", "git+https", "git+ssh"} diff --git a/src/poetry/utils/env/base_env.py b/src/poetry/utils/env/base_env.py index 7c5574c19e3..d3f4a3be18c 100644 --- a/src/poetry/utils/env/base_env.py +++ b/src/poetry/utils/env/base_env.py @@ -23,15 +23,13 @@ if TYPE_CHECKING: - from typing import Tuple - from packaging.tags import Tag from poetry.core.version.markers import BaseMarker from virtualenv.seed.wheels.util import Wheel from poetry.utils.env.generic_env import GenericEnv - PythonVersion = Tuple[int, int, int, str, int] + PythonVersion = tuple[int, int, int, str, int] class Env(ABC): diff --git a/src/poetry/utils/isolated_build.py b/src/poetry/utils/isolated_build.py index 5879676c691..abbd468f991 100644 --- a/src/poetry/utils/isolated_build.py +++ b/src/poetry/utils/isolated_build.py @@ -6,8 +6,6 @@ from contextlib import redirect_stdout from io import StringIO from typing import TYPE_CHECKING -from typing import Collection -from typing import Iterator from build.env import IsolatedEnv as BaseIsolatedEnv @@ -17,6 +15,8 @@ if TYPE_CHECKING: + from collections.abc import Collection + from collections.abc import Iterator from pathlib import Path from build import DistributionType diff --git a/tests/conftest.py b/tests/conftest.py index e8d289a1931..f666f5b3d81 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,10 +7,10 @@ import shutil import sys +from collections.abc import Iterator from pathlib import Path from typing import TYPE_CHECKING from typing import Any -from typing import Iterator import httpretty import keyring diff --git a/tests/console/commands/test_check.py b/tests/console/commands/test_check.py index 1496ebcd544..5d0b0226d8d 100644 --- a/tests/console/commands/test_check.py +++ b/tests/console/commands/test_check.py @@ -10,7 +10,7 @@ if TYPE_CHECKING: - from typing import Iterator + from collections.abc import Iterator from cleo.testers.command_tester import CommandTester from pytest_mock import MockerFixture diff --git a/tests/helpers.py b/tests/helpers.py index d8211e7fc1a..2bf188fe31a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -24,8 +24,8 @@ if TYPE_CHECKING: from collections.abc import Iterator + from collections.abc import Mapping from typing import Any - from typing import Mapping import httpretty diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index d0e4ac14dec..62c1f77732a 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -4,7 +4,6 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING -from typing import Iterator from zipfile import ZipFile import pytest @@ -20,6 +19,7 @@ if TYPE_CHECKING: + from collections.abc import Iterator from pathlib import Path from packaging.metadata import RawMetadata diff --git a/tests/integration/test_utils_vcs_git.py b/tests/integration/test_utils_vcs_git.py index 5411739b229..55e11674a6a 100644 --- a/tests/integration/test_utils_vcs_git.py +++ b/tests/integration/test_utils_vcs_git.py @@ -7,7 +7,6 @@ from hashlib import sha1 from pathlib import Path from typing import TYPE_CHECKING -from typing import Iterator from typing import TypedDict from urllib.parse import urlparse from urllib.parse import urlunparse @@ -27,6 +26,8 @@ if TYPE_CHECKING: + from collections.abc import Iterator + from dulwich.client import FetchPackResult from dulwich.client import GitClient from pytest import TempPathFactory diff --git a/tests/masonry/builders/test_editable_builder.py b/tests/masonry/builders/test_editable_builder.py index 82c63426b90..b7e7c116cde 100644 --- a/tests/masonry/builders/test_editable_builder.py +++ b/tests/masonry/builders/test_editable_builder.py @@ -7,7 +7,6 @@ from pathlib import Path from typing import TYPE_CHECKING -from typing import Iterator import pytest @@ -29,6 +28,8 @@ if TYPE_CHECKING: + from collections.abc import Iterator + from pytest_mock import MockerFixture from poetry.poetry import Poetry diff --git a/tests/packages/test_locker.py b/tests/packages/test_locker.py index 32747c8a26e..080b9fb4d03 100644 --- a/tests/packages/test_locker.py +++ b/tests/packages/test_locker.py @@ -1140,11 +1140,13 @@ def test_lock_file_resolves_file_url_symlinks(root: ProjectPackage) -> None: """ with tempfile.TemporaryDirectory() as d1: symlink_path = Path(d1).joinpath("testsymlink") - with tempfile.TemporaryDirectory(dir=d1) as d2, tempfile.TemporaryDirectory( - dir=d1 - ) as d4, tempfile.TemporaryDirectory(dir=d2) as d3, tempfile.NamedTemporaryFile( - dir=d4 - ) as source_file, tempfile.NamedTemporaryFile(dir=d3) as lock_file: + with ( + tempfile.TemporaryDirectory(dir=d1) as d2, + tempfile.TemporaryDirectory(dir=d1) as d4, + tempfile.TemporaryDirectory(dir=d2) as d3, + tempfile.NamedTemporaryFile(dir=d4) as source_file, + tempfile.NamedTemporaryFile(dir=d3) as lock_file, + ): lock_file.close() try: os.symlink(Path(d3), symlink_path) diff --git a/tests/repositories/fixtures/pypi.org/generate.py b/tests/repositories/fixtures/pypi.org/generate.py index 1b84562a2d5..d247eb18233 100644 --- a/tests/repositories/fixtures/pypi.org/generate.py +++ b/tests/repositories/fixtures/pypi.org/generate.py @@ -48,7 +48,6 @@ from typing import TYPE_CHECKING from typing import Any from typing import Callable -from typing import Iterator from packaging.metadata import parse_email from poetry.core.masonry.utils.helpers import normalize_file_permissions @@ -64,6 +63,8 @@ if TYPE_CHECKING: + from collections.abc import Iterator + import requests from poetry.core.packages.utils.link import Link @@ -325,9 +326,13 @@ def process_zipfile(self, link: Link) -> ReleaseFileMetadata: dst.relative_to(FIXTURE_PATH_REPOSITORIES_PYPI), ) - with self.pypi._cached_or_downloaded_file(link) as src, zipfile.ZipFile( - dst, "w", compression=zipfile.ZIP_DEFLATED - ) as stubbed_sdist, zipfile.ZipFile(src) as zf: + with ( + self.pypi._cached_or_downloaded_file(link) as src, + zipfile.ZipFile( + dst, "w", compression=zipfile.ZIP_DEFLATED + ) as stubbed_sdist, + zipfile.ZipFile(src) as zf, + ): for member in zf.infolist(): if not is_protected(member.filename): logger.debug("Stubbing file %s(%s)", link.filename, member.filename) @@ -350,11 +355,14 @@ def process_tarfile(self, link: Link) -> ReleaseFileMetadata: dst.relative_to(FIXTURE_PATH_REPOSITORIES_PYPI), ) - with self.pypi._cached_or_downloaded_file(link) as src, GzipFile( - dst.as_posix(), mode="wb", mtime=0 - ) as gz, tarfile.TarFile( - dst, mode="w", fileobj=gz, format=tarfile.PAX_FORMAT - ) as dst_tf, tarfile.open(src, "r") as src_tf: + with ( + self.pypi._cached_or_downloaded_file(link) as src, + GzipFile(dst.as_posix(), mode="wb", mtime=0) as gz, + tarfile.TarFile( + dst, mode="w", fileobj=gz, format=tarfile.PAX_FORMAT + ) as dst_tf, + tarfile.open(src, "r") as src_tf, + ): for member in src_tf.getmembers(): member.uid = 0 member.gid = 0 diff --git a/tests/repositories/fixtures/python_hosted.py b/tests/repositories/fixtures/python_hosted.py index a00f494e916..fcda8724408 100644 --- a/tests/repositories/fixtures/python_hosted.py +++ b/tests/repositories/fixtures/python_hosted.py @@ -2,10 +2,10 @@ import re +from collections.abc import Iterator from pathlib import Path from typing import TYPE_CHECKING from typing import Any -from typing import Iterator from urllib.parse import urlparse import pytest diff --git a/tests/repositories/test_installed_repository.py b/tests/repositories/test_installed_repository.py index 2f309dfea24..622b8ea0cfa 100644 --- a/tests/repositories/test_installed_repository.py +++ b/tests/repositories/test_installed_repository.py @@ -7,7 +7,6 @@ from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING -from typing import Iterator from typing import NamedTuple import pytest @@ -22,6 +21,8 @@ if TYPE_CHECKING: + from collections.abc import Iterator + from poetry.core.packages.package import Package from pytest import LogCaptureFixture from pytest_mock.plugin import MockerFixture diff --git a/tests/types.py b/tests/types.py index 840545bf27f..a9b2e8079d9 100644 --- a/tests/types.py +++ b/tests/types.py @@ -7,10 +7,8 @@ if TYPE_CHECKING: from collections.abc import Callable + from contextlib import AbstractContextManager from pathlib import Path - from typing import ContextManager - from typing import Dict - from typing import Tuple from cleo.io.io import IO from cleo.testers.command_tester import CommandTester @@ -26,9 +24,9 @@ from poetry.utils.env import Env from tests.repositories.fixtures.distribution_hashes import DistributionHash - HTTPrettyResponse = Tuple[int, Dict[str, Any], bytes] # status code, headers, body + HTTPrettyResponse = tuple[int, dict[str, Any], bytes] # status code, headers, body HTTPrettyRequestCallback = Callable[ - [HTTPrettyRequest, str, Dict[str, Any]], HTTPrettyResponse + [HTTPrettyRequest, str, dict[str, Any]], HTTPrettyResponse ] HTTPPrettyRequestCallbackWrapper = Callable[ [HTTPrettyRequestCallback], HTTPrettyRequestCallback @@ -111,4 +109,4 @@ def __call__(self, name: str) -> DistributionHash: ... class SetProjectContext(Protocol): def __call__( self, project: str | Path, in_place: bool = False - ) -> ContextManager[Path]: ... + ) -> AbstractContextManager[Path]: ... diff --git a/tests/utils/env/test_env.py b/tests/utils/env/test_env.py index 15aaf4cfac8..b7462eab3bb 100644 --- a/tests/utils/env/test_env.py +++ b/tests/utils/env/test_env.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: - from typing import Iterator + from collections.abc import Iterator from pytest_mock import MockerFixture From 97269787b2263bebbf248fd9e00043fc89aacf52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:41:44 +0200 Subject: [PATCH 2/5] simplify code with parameter introduced in Python 3.9 Co-authored-by: Sven van Ashbrook --- src/poetry/installation/executor.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index 2f5f550a619..4423911eb40 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -209,10 +209,7 @@ def _serialize( self._shutdown = True if self._shutdown: - # Cancelling further tasks from being executed - [task.cancel() for task in tasks] - self._executor.shutdown(wait=True) - + self._executor.shutdown(wait=True, cancel_futures=True) break for warning in self._yanked_warnings: From dbfc5fcadfa754777b5d873aaf0b14c43fbef34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:09:07 +0200 Subject: [PATCH 3/5] fix export tests --- .github/workflows/.tests-matrix.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/.tests-matrix.yaml b/.github/workflows/.tests-matrix.yaml index 605f8e6f2bd..cd4902e6ad3 100644 --- a/.github/workflows/.tests-matrix.yaml +++ b/.github/workflows/.tests-matrix.yaml @@ -101,7 +101,11 @@ jobs: - name: Use local poetry working-directory: poetry-plugin-export - run: poetry add --lock --group dev ../poetry + # Replace the python version to avoid conflicts + # if the plugin still supports a wider range than Poetry itself. + run: | + sed -i 's/^python =.*$/python = "~${{ inputs.python-version }}"/' pyproject.toml + poetry add --lock --group dev ../poetry # This step can be removed after having released a poetry-plugin-export version # that has cffi>=1.17.0 in its lock file. From 27424be89a4fdb9c5f3a28e613129cc6ccd1136d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:28:19 +0200 Subject: [PATCH 4/5] use perl because sed on macOS is different --- .github/workflows/.tests-matrix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.tests-matrix.yaml b/.github/workflows/.tests-matrix.yaml index cd4902e6ad3..c3869f1d572 100644 --- a/.github/workflows/.tests-matrix.yaml +++ b/.github/workflows/.tests-matrix.yaml @@ -104,7 +104,7 @@ jobs: # Replace the python version to avoid conflicts # if the plugin still supports a wider range than Poetry itself. run: | - sed -i 's/^python =.*$/python = "~${{ inputs.python-version }}"/' pyproject.toml + perl -pi -e 's/^python =.*$/python = "~${{ inputs.python-version }}"/' pyproject.toml poetry add --lock --group dev ../poetry # This step can be removed after having released a poetry-plugin-export version From e9537c47319e189822e52dba2836c7e20dea4c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 20 Oct 2024 12:45:55 +0200 Subject: [PATCH 5/5] relock because of missing PyYAML wheels --- poetry.lock | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/poetry.lock b/poetry.lock index 2a2b4f22489..bca90648273 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1195,6 +1195,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1202,8 +1203,16 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1220,6 +1229,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1227,6 +1237,7 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"},