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-matrix.yaml b/.github/workflows/.tests-matrix.yaml
index 605f8e6f2bd..c3869f1d572 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: |
+ 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
# that has cffi>=1.17.0 in its lock file.
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..bca90648273 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"},
]
@@ -1630,5 +1610,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/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:
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