diff --git a/.flake8 b/.flake8 index 2d16cf2abc3..2780c9c145e 100644 --- a/.flake8 +++ b/.flake8 @@ -6,7 +6,7 @@ ban-relative-imports = true format-greedy = 1 inline-quotes = double enable-extensions = TC, TC1 -type-checking-exempt-modules = typing, typing-extensions +type-checking-strict = true eradicate-whitelist-extend = ^-.*; extend-ignore = # E203: Whitespace before ':' (pycqa/pycodestyle#373) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c4e363a2d8f..34d488fee6d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: os: [Ubuntu, macOS, Windows] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] include: - os: Ubuntu image: ubuntu-22.04 @@ -83,11 +83,6 @@ jobs: # Using `timeout` is a safeguard against the Poetry command hanging for some reason. timeout 10s poetry run pip --version || rm -rf .venv - # XXX: https://github.com/pypa/pip/issues/11352 causes random failures -- remove once fixed in a release. - - name: Upgrade pip on Python 3.11 - if: ${{ matrix.python-version == '3.11-dev' }} - run: poetry run pip install git+https://github.com/pypa/pip.git@f8a25921e5c443b07483017b0ffdeb08b9ba2fdf - - name: Install dependencies run: poetry install --with github-actions diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 27563811d61..17577f47aca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: - flake8-quotes==3.3.1 - flake8-simplify==0.19.3 - flake8-tidy-imports==4.8.0 - - flake8-type-checking==2.1.2 + - flake8-type-checking==2.2.0 - flake8-typing-imports==1.12.0 - flake8-use-fstring==1.4 - pep8-naming==0.13.1 diff --git a/LICENSE b/LICENSE index 44cf2b30e68..81a8e1e4739 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018 Sébastien Eustace +Copyright (c) 2018-present Sébastien Eustace Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/docs/dependency-specification.md b/docs/dependency-specification.md index b841d68bc10..3e7f55f755f 100644 --- a/docs/dependency-specification.md +++ b/docs/dependency-specification.md @@ -247,7 +247,7 @@ for extras in your project refer to [`extras`]({{< relref "pyproject#extras" >}} ## `source` dependencies -To depend on a package from an [alternate repository]({{< relref "repositories/#install-dependencies-from-a-private-repository" >}}), +To depend on a package from an [alternate repository]({{< relref "repositories#installing-from-private-package-sources" >}}), you can use the `source` property: ```toml @@ -267,7 +267,7 @@ poetry add my-cool-package --source foo ``` {{% note %}} -In this example, we expect `foo` to be configured correctly. See [using a private repository](repositories.md#using-a-private-repository) +In this example, we expect `foo` to be configured correctly. See [using a private repository]({{< relref "repositories#installing-from-private-package-sources" >}}) for further information. {{% /note %}} diff --git a/src/poetry/factory.py b/src/poetry/factory.py index 46856736354..c20f224272c 100644 --- a/src/poetry/factory.py +++ b/src/poetry/factory.py @@ -257,7 +257,8 @@ def create_pyproject_from_package( constraint["optional"] = True if len(constraint) == 1 and "version" in constraint: - constraint = cast(str, constraint["version"]) + assert isinstance(constraint["version"], str) + constraint = constraint["version"] elif not constraint: constraint = "*" diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index 2dc53d53016..e831d4d0d34 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -13,7 +13,6 @@ from subprocess import CalledProcessError from typing import TYPE_CHECKING from typing import Any -from typing import cast from cleo.io.null_io import NullIO from poetry.core.packages.file_dependency import FileDependency @@ -771,7 +770,8 @@ def _save_url_reference(self, operation: Operation) -> None: for dist in self._env.site_packages.distributions( name=package.name, writable_only=True ): - dist_path = cast(Path, dist._path) # type: ignore[attr-defined] + dist_path = dist._path # type: ignore[attr-defined] + assert isinstance(dist_path, Path) url = dist_path / "direct_url.json" url.write_text(json.dumps(url_reference), encoding="utf-8") diff --git a/src/poetry/mixology/failure.py b/src/poetry/mixology/failure.py index f4629aa56c7..448d39786bb 100644 --- a/src/poetry/mixology/failure.py +++ b/src/poetry/mixology/failure.py @@ -1,7 +1,6 @@ from __future__ import annotations from typing import TYPE_CHECKING -from typing import cast from poetry.core.constraints.version import parse_constraint @@ -114,7 +113,8 @@ def _visit( conjunction = "So," if conclusion or incompatibility == self._root else "And" incompatibility_string = str(incompatibility) - cause: ConflictCause = cast(ConflictCause, incompatibility.cause) + cause = incompatibility.cause + assert isinstance(cause, ConflictCause) if isinstance(cause.conflict.cause, ConflictCause) and isinstance( cause.other.cause, ConflictCause @@ -198,7 +198,8 @@ def _visit( numbered=numbered, ) elif self._is_collapsible(derived): - derived_cause: ConflictCause = cast(ConflictCause, derived.cause) + derived_cause = derived.cause + assert isinstance(derived_cause, ConflictCause) if isinstance(derived_cause.conflict.cause, ConflictCause): collapsed_derived = derived_cause.conflict collapsed_ext = derived_cause.other @@ -233,7 +234,8 @@ def _is_collapsible(self, incompatibility: Incompatibility) -> bool: if self._derivations[incompatibility] > 1: return False - cause: ConflictCause = cast(ConflictCause, incompatibility.cause) + cause = incompatibility.cause + assert isinstance(cause, ConflictCause) if isinstance(cause.conflict.cause, ConflictCause) and isinstance( cause.other.cause, ConflictCause ): diff --git a/src/poetry/utils/env.py b/src/poetry/utils/env.py index d76972ca50d..7de0d60d2bc 100644 --- a/src/poetry/utils/env.py +++ b/src/poetry/utils/env.py @@ -451,12 +451,6 @@ def find( if value[-1] is True ] - def __getattr__(self, item: str) -> Any: - try: - return super().__getattribute__(item) - except AttributeError: - return getattr(self.path, item) - class EnvError(Exception): pass diff --git a/src/poetry/utils/helpers.py b/src/poetry/utils/helpers.py index b50d9e9acfc..c4ef660d547 100644 --- a/src/poetry/utils/helpers.py +++ b/src/poetry/utils/helpers.py @@ -12,7 +12,6 @@ from typing import Any from typing import Iterator from typing import Mapping -from typing import cast from poetry.utils.constants import REQUESTS_TIMEOUT @@ -189,7 +188,8 @@ def _get_win_folder_from_registry(csidl_name: str) -> str: ) dir, type = _winreg.QueryValueEx(key, shell_folder_name) - return cast(str, dir) + assert isinstance(dir, str) + return dir def _get_win_folder_with_ctypes(csidl_name: str) -> str: