Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typechecking tidying #386

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/poetry/core/packages/constraints/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions src/poetry/core/packages/constraints/multi_constraint.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/poetry/core/packages/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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

Expand Down
24 changes: 8 additions & 16 deletions src/poetry/core/packages/utils/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -56,40 +50,38 @@ 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"<Link {self!s}>"

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
Expand Down
3 changes: 1 addition & 2 deletions src/poetry/core/semver/version_union.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 Any

from poetry.core.semver.empty_constraint import EmptyConstraint
from poetry.core.semver.version_constraint import VersionConstraint
Expand Down Expand Up @@ -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

Expand Down