Skip to content

Commit

Permalink
PEP 585 (#5643)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyllanesc authored May 19, 2022
1 parent f3439da commit c880cd7
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/poetry/config/file_config_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from contextlib import contextmanager
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterator

from tomlkit import document
from tomlkit import table
Expand All @@ -12,6 +11,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from poetry.core.toml.file import TOMLFile
from tomlkit.toml_document import TOMLDocument

Expand Down
8 changes: 5 additions & 3 deletions src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import ContextManager
from typing import Iterator
from typing import cast

import pkginfo
Expand All @@ -31,6 +29,8 @@

if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Iterator
from contextlib import AbstractContextManager

from poetry.core.packages.project_package import ProjectPackage

Expand Down Expand Up @@ -281,7 +281,9 @@ def _from_sdist_file(cls, path: Path) -> PackageInfo:
# So, we unpack and introspect
suffix = path.suffix

context: Callable[[str], ContextManager[zipfile.ZipFile | tarfile.TarFile]]
context: Callable[
[str], AbstractContextManager[zipfile.ZipFile | tarfile.TarFile]
]
if suffix == ".zip":
context = zipfile.ZipFile
else:
Expand Down
5 changes: 3 additions & 2 deletions src/poetry/installation/installer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Iterable
from typing import Sequence

from cleo.io.null_io import NullIO

Expand All @@ -20,6 +18,9 @@


if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Sequence

from cleo.io.io import IO
from poetry.core.packages.project_package import ProjectPackage

Expand Down
3 changes: 2 additions & 1 deletion src/poetry/layouts/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Mapping

from tomlkit import dumps
from tomlkit import inline_table
Expand All @@ -16,6 +15,8 @@


if TYPE_CHECKING:
from typing import Mapping

from poetry.core.pyproject.toml import PyProjectTOML
from tomlkit.items import InlineTable

Expand Down
2 changes: 1 addition & 1 deletion src/poetry/mixology/incompatibility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Iterator

from poetry.mixology.incompatibility_cause import ConflictCause
from poetry.mixology.incompatibility_cause import DependencyCause
Expand All @@ -14,6 +13,7 @@

if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Iterator

from poetry.mixology.incompatibility_cause import IncompatibilityCause
from poetry.mixology.term import Term
Expand Down
7 changes: 4 additions & 3 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterable
from typing import Iterator
from typing import Sequence
from typing import cast

from poetry.core.packages.dependency import Dependency
Expand Down Expand Up @@ -40,6 +37,10 @@


if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence

from poetry.core.version.markers import BaseMarker
from tomlkit.toml_document import TOMLDocument

Expand Down
3 changes: 2 additions & 1 deletion src/poetry/packages/package_collection.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Sequence

from poetry.packages.dependency_package import DependencyPackage


if TYPE_CHECKING:
from collections.abc import Sequence

from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package

Expand Down
4 changes: 2 additions & 2 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterable
from typing import Iterator
from typing import cast

from cleo.ui.progress_indicator import ProgressIndicator
Expand Down Expand Up @@ -43,6 +41,8 @@

if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Iterable
from collections.abc import Iterator

from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/puzzle/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from contextlib import contextmanager
from typing import TYPE_CHECKING
from typing import FrozenSet
from typing import Iterator
from typing import Tuple
from typing import TypeVar

Expand All @@ -25,6 +24,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from cleo.io.io import IO
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.directory_dependency import DirectoryDependency
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/repositories/link_sources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from abc import abstractmethod
from typing import TYPE_CHECKING
from typing import Iterator

from poetry.core.packages.package import Package
from poetry.core.semver.version import Version
Expand All @@ -16,6 +15,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from poetry.core.packages.utils.link import Link


Expand Down
5 changes: 4 additions & 1 deletion src/poetry/repositories/link_sources/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import warnings

from html import unescape
from typing import Iterator
from typing import TYPE_CHECKING

from poetry.core.packages.utils.link import Link

from poetry.repositories.link_sources.base import LinkSource


if TYPE_CHECKING:
from collections.abc import Iterator

with warnings.catch_warnings():
warnings.simplefilter("ignore")
import html5lib
Expand Down
5 changes: 3 additions & 2 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from subprocess import CalledProcessError
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterable
from typing import Iterator
from typing import TypeVar

import packaging.tags
Expand Down Expand Up @@ -49,6 +47,9 @@


if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Iterator

from cleo.io.io import IO
from poetry.core.version.markers import BaseMarker

Expand Down
9 changes: 5 additions & 4 deletions src/poetry/utils/extras.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Iterable
from typing import Iterator
from typing import Mapping
from typing import Sequence


if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Iterator
from collections.abc import Sequence
from typing import Mapping

from poetry.core.packages.package import Package


Expand Down
2 changes: 1 addition & 1 deletion src/poetry/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import stat
import tempfile

from collections.abc import Mapping
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Mapping


if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re

from typing import TYPE_CHECKING
from typing import Iterator

import pytest

Expand All @@ -17,6 +16,7 @@

if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Iterator
from pathlib import Path


Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterator
from typing import TextIO

import httpretty
Expand Down Expand Up @@ -40,6 +39,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from _pytest.config import Config as PyTestConfig
from _pytest.config.argparsing import Parser
from pytest_mock import MockerFixture
Expand Down
3 changes: 2 additions & 1 deletion tests/console/commands/env/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Iterator

import pytest

from poetry.utils.env import EnvManager


if TYPE_CHECKING:
from collections.abc import Iterator

from tests.helpers import PoetryTestApplication


Expand Down
3 changes: 2 additions & 1 deletion tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Iterator

import pytest

Expand All @@ -20,6 +19,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from _pytest.fixtures import FixtureRequest
from poetry.core.packages.package import Package
from pytest_mock import MockerFixture
Expand Down
3 changes: 2 additions & 1 deletion tests/console/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Iterator

import pytest

Expand All @@ -24,6 +23,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from pytest_mock import MockerFixture

from poetry.installation.executor import Executor
Expand Down
3 changes: 2 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterator

from poetry.core.masonry.utils.helpers import escape_name
from poetry.core.masonry.utils.helpers import escape_version
Expand All @@ -29,6 +28,8 @@


if TYPE_CHECKING:
from collections.abc import Iterator

from poetry.core.packages.dependency import Dependency
from poetry.core.semver.version import Version
from tomlkit.toml_document import TOMLDocument
Expand Down
3 changes: 2 additions & 1 deletion tests/repositories/link_sources/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Iterable
from unittest.mock import PropertyMock

import pytest
Expand All @@ -14,6 +13,8 @@


if TYPE_CHECKING:
from collections.abc import Iterable

from pytest_mock import MockerFixture


Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Iterator

import pytest
import tomlkit
Expand All @@ -34,6 +33,7 @@

if TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Iterator

from pytest_mock import MockerFixture

Expand Down

0 comments on commit c880cd7

Please sign in to comment.