From 8379c7627487acf3676072efe6d84bfd7ca6081f Mon Sep 17 00:00:00 2001 From: David Hotham Date: Thu, 2 Jun 2022 14:49:00 +0100 Subject: [PATCH 1/2] tidying some typechecking --- src/poetry/core/packages/constraints/constraint.py | 4 +--- .../core/packages/constraints/multi_constraint.py | 4 +--- src/poetry/core/packages/dependency.py | 3 +-- src/poetry/core/packages/utils/link.py | 12 ++++++------ src/poetry/core/semver/version_union.py | 3 +-- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/poetry/core/packages/constraints/constraint.py b/src/poetry/core/packages/constraints/constraint.py index 9e6d042fc..015510810 100644 --- a/src/poetry/core/packages/constraints/constraint.py +++ b/src/poetry/core/packages/constraints/constraint.py @@ -2,8 +2,6 @@ import operator -from typing import Any - from poetry.core.packages.constraints import AnyConstraint from poetry.core.packages.constraints.base_constraint import BaseConstraint from poetry.core.packages.constraints.empty_constraint import EmptyConstraint @@ -128,7 +126,7 @@ def is_any(self) -> bool: def is_empty(self) -> bool: return False - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: if not isinstance(other, Constraint): return NotImplemented diff --git a/src/poetry/core/packages/constraints/multi_constraint.py b/src/poetry/core/packages/constraints/multi_constraint.py index 76ae8c7f0..8ab75fecf 100644 --- a/src/poetry/core/packages/constraints/multi_constraint.py +++ b/src/poetry/core/packages/constraints/multi_constraint.py @@ -1,7 +1,5 @@ from __future__ import annotations -from typing import Any - from poetry.core.packages.constraints.base_constraint import BaseConstraint from poetry.core.packages.constraints.constraint import Constraint @@ -77,7 +75,7 @@ def intersect(self, other: BaseConstraint) -> BaseConstraint: return MultiConstraint(*constraints) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: if not isinstance(other, MultiConstraint): return False diff --git a/src/poetry/core/packages/dependency.py b/src/poetry/core/packages/dependency.py index 5d75cd2e6..413d68b31 100644 --- a/src/poetry/core/packages/dependency.py +++ b/src/poetry/core/packages/dependency.py @@ -7,7 +7,6 @@ from contextlib import suppress from pathlib import Path from typing import TYPE_CHECKING -from typing import Any from typing import Iterable from poetry.core.packages.constraints import ( @@ -587,7 +586,7 @@ def create_from_pep_508( return dep - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: if not isinstance(other, Dependency): return NotImplemented diff --git a/src/poetry/core/packages/utils/link.py b/src/poetry/core/packages/utils/link.py index 86367e475..bfa0fde6c 100644 --- a/src/poetry/core/packages/utils/link.py +++ b/src/poetry/core/packages/utils/link.py @@ -64,32 +64,32 @@ def __str__(self) -> str: def __repr__(self) -> str: return f"" - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: if not isinstance(other, Link): return NotImplemented return self.url == other.url - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: if not isinstance(other, Link): return NotImplemented return self.url != other.url - def __lt__(self, other: Any) -> bool: + def __lt__(self, other: object) -> bool: if not isinstance(other, Link): return NotImplemented return self.url < other.url - def __le__(self, other: Any) -> bool: + def __le__(self, other: object) -> bool: if not isinstance(other, Link): return NotImplemented return self.url <= other.url - def __gt__(self, other: Any) -> bool: + def __gt__(self, other: object) -> bool: if not isinstance(other, Link): return NotImplemented return self.url > other.url - def __ge__(self, other: Any) -> bool: + def __ge__(self, other: object) -> bool: if not isinstance(other, Link): return NotImplemented return self.url >= other.url diff --git a/src/poetry/core/semver/version_union.py b/src/poetry/core/semver/version_union.py index da4502d6c..26edb7426 100644 --- a/src/poetry/core/semver/version_union.py +++ b/src/poetry/core/semver/version_union.py @@ -1,7 +1,6 @@ from __future__ import annotations from typing import TYPE_CHECKING -from typing import Any from poetry.core.semver.empty_constraint import EmptyConstraint from poetry.core.semver.version_constraint import VersionConstraint @@ -395,7 +394,7 @@ def excludes_single_version(self) -> bool: return isinstance(VersionRange().difference(self), Version) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: if not isinstance(other, VersionUnion): return False From 9a007ccc83078e8cb8ad765399ff0c9d0d8e7de1 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Thu, 2 Jun 2022 17:32:19 +0100 Subject: [PATCH 2/2] remove unused Link parameters --- src/poetry/core/packages/utils/link.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/poetry/core/packages/utils/link.py b/src/poetry/core/packages/utils/link.py index bfa0fde6c..8cbda0fd6 100644 --- a/src/poetry/core/packages/utils/link.py +++ b/src/poetry/core/packages/utils/link.py @@ -4,8 +4,6 @@ import re import urllib.parse as urlparse -from typing import Any - from poetry.core.packages.utils.utils import path_to_url from poetry.core.packages.utils.utils import splitext @@ -14,7 +12,6 @@ class Link: def __init__( self, url: str, - comes_from: Any | None = None, requires_python: str | None = None, metadata: str | bool | None = None, ) -> None: @@ -23,8 +20,6 @@ def __init__( url: url of the resource pointed to (href of the link) - comes_from: - instance of HTMLPage where the link was found, or string. requires_python: String containing the `Requires-Python` metadata field, specified in PEP 345. This may be specified by a data-requires-python @@ -41,7 +36,6 @@ def __init__( url = path_to_url(url) self.url = url - self.comes_from = comes_from self.requires_python = requires_python if requires_python else None if isinstance(metadata, str): @@ -56,10 +50,8 @@ def __str__(self) -> str: rp = f" (requires-python:{self.requires_python})" else: rp = "" - if self.comes_from: - return f"{self.url} (from {self.comes_from}){rp}" - else: - return str(self.url) + + return f"{self.url}{rp}" def __repr__(self) -> str: return f""