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 72aecab2a4b..51ad38e5f91 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -123,7 +123,7 @@ jobs:
image: windows-2022
- name: macOS aarch64
image: macos-14
- python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
status:
diff --git a/poetry.lock b/poetry.lock
index 484af427d5f..478254d029c 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -606,24 +606,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"
@@ -728,7 +710,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" = "*"
@@ -1012,7 +993,7 @@ name = "psutil"
version = "6.0.0"
description = "Cross-platform lib for process and system monitoring in Python."
optional = false
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"
files = [
{file = "psutil-6.0.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a021da3e881cd935e64a3d0a20983bda0bb4cf80e4f74fa9bfcb1bc5785360c6"},
{file = "psutil-6.0.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:1287c2b95f1c0a364d23bc6f2ea2365a8d4d9b726a3be7294296ff7ba97c17f0"},
@@ -1199,7 +1180,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"},
@@ -1207,16 +1187,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"},
@@ -1233,7 +1205,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"},
@@ -1241,7 +1212,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"},
@@ -1614,5 +1584,5 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools",
[metadata]
lock-version = "2.0"
-python-versions = "^3.8"
-content-hash = "441837efd1e7f3926ede309d5d5f71a7b25d86ca01a91e96afe0ae63851bfbb8"
+python-versions = "^3.9"
+content-hash = "33a15132ef8335c7230206d60219055a5a0a30f7d1e568c2f04fb978540e84aa"
diff --git a/pyproject.toml b/pyproject.toml
index 30d4c958623..db8c4978f43 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/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 19f260e58b2..9ccfbd726a2 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 491cec88a91..318400416c0 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 069566a22c5..8e8aeee56c6 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 _pytest.tmpdir import TempPathFactory
from dulwich.client import FetchPackResult
from dulwich.client import GitClient
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 0c3203b0b1d..0d449a89d1e 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 ccc535dcc55..e452d894df8 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.builders.sdist import SdistBuilder
@@ -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.mtime = 0
member = SdistBuilder.clean_tarinfo(member)
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 204e8ca94af..751e141bdf1 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 _pytest.logging import LogCaptureFixture
from poetry.core.packages.package import Package
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