From 41abc1a52c29b6735adfae63c455412ffbb6dacf Mon Sep 17 00:00:00 2001 From: Vlad Kooklev Date: Mon, 24 Oct 2022 12:35:39 +0400 Subject: [PATCH 1/5] chore: Update outdated LICENSE year (#6871) Updated the outdated copyright year to the present. So there will not be a need for any further license year updates --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 5c578a2988b1725ba5042f198c9bb3efa0c77db8 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Mon, 24 Oct 2022 04:06:59 -0600 Subject: [PATCH 2/5] fix(docs): broken link in dependency-specification (#6842) Co-authored-by: Bartosz Sokorski --- docs/dependency-specification.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 %}} From c9e6d5e4c6abdd0296f2467a674cf21e59bef42a Mon Sep 17 00:00:00 2001 From: David Hotham Date: Mon, 24 Oct 2022 16:57:57 +0100 Subject: [PATCH 3/5] remove getattr from SitePackages (#6867) `__getattr__` can be cute and all, but it's unhelpful for typechecking (and human code readers): suddenly any attribute on an object might be valid, and might return any type at all. mypy and the unit tests agree that no use is made of the `__getattr__` on `SitePackages` anyway, so removing it is simply making it clear that there is no magic. --- src/poetry/utils/env.py | 6 ------ 1 file changed, 6 deletions(-) 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 From 1af6e238d894fd7254c6d80a4dd89d0170df2206 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Mon, 24 Oct 2022 17:30:28 +0100 Subject: [PATCH 4/5] strict flake8-type-checking (#6866) recent flake8-type-checking encourages cast() using the name of the class rather than the actual class, presumably with the aim that you might find more things you don't need to import at runtime however here, consistent with other recent MRs, I've taken the view that it's better to assert that you have the expected type than to trust that it's so --- .flake8 | 2 +- .pre-commit-config.yaml | 2 +- src/poetry/factory.py | 3 ++- src/poetry/installation/executor.py | 4 ++-- src/poetry/mixology/failure.py | 10 ++++++---- src/poetry/utils/helpers.py | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) 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/.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/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/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: From 4a07b5e0243bb8879dd6725cb901d9fa0f6eb182 Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Wed, 26 Oct 2022 14:15:48 +0200 Subject: [PATCH 5/5] Switch from -dev to released 3.11 version (#6882) As in title, switching Python 3.11 in CI from beta to full release --- .github/workflows/main.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) 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