diff --git a/lib/packaging/__about__.py b/lib/packaging/__about__.py index e70d692c..3551bc2d 100644 --- a/lib/packaging/__about__.py +++ b/lib/packaging/__about__.py @@ -17,7 +17,7 @@ __title__ = "packaging" __summary__ = "Core utilities for Python packages" __uri__ = "https://github.com/pypa/packaging" -__version__ = "21.0" +__version__ = "21.3" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" diff --git a/lib/packaging/_musllinux.py b/lib/packaging/_musllinux.py index 85450faf..8ac3059b 100644 --- a/lib/packaging/_musllinux.py +++ b/lib/packaging/_musllinux.py @@ -98,7 +98,7 @@ def _get_musl_version(executable: str) -> Optional[_MuslVersion]: with contextlib.ExitStack() as stack: try: f = stack.enter_context(open(executable, "rb")) - except IOError: + except OSError: return None ld = _parse_ld_musl_from_elf(f) if not ld: diff --git a/lib/packaging/_structures.py b/lib/packaging/_structures.py index 95154975..90a6465f 100644 --- a/lib/packaging/_structures.py +++ b/lib/packaging/_structures.py @@ -19,9 +19,6 @@ class InfinityType: def __eq__(self, other: object) -> bool: return isinstance(other, self.__class__) - def __ne__(self, other: object) -> bool: - return not isinstance(other, self.__class__) - def __gt__(self, other: object) -> bool: return True @@ -51,9 +48,6 @@ class NegativeInfinityType: def __eq__(self, other: object) -> bool: return isinstance(other, self.__class__) - def __ne__(self, other: object) -> bool: - return not isinstance(other, self.__class__) - def __gt__(self, other: object) -> bool: return False diff --git a/lib/packaging/specifiers.py b/lib/packaging/specifiers.py index ce66bd4a..0e218a6f 100644 --- a/lib/packaging/specifiers.py +++ b/lib/packaging/specifiers.py @@ -57,13 +57,6 @@ class BaseSpecifier(metaclass=abc.ABCMeta): objects are equal. """ - @abc.abstractmethod - def __ne__(self, other: object) -> bool: - """ - Returns a boolean representing whether or not the two Specifier like - objects are not equal. - """ - @abc.abstractproperty def prereleases(self) -> Optional[bool]: """ @@ -119,7 +112,7 @@ class _IndividualSpecifier(BaseSpecifier): else "" ) - return "<{}({!r}{})>".format(self.__class__.__name__, str(self), pre) + return f"<{self.__class__.__name__}({str(self)!r}{pre})>" def __str__(self) -> str: return "{}{}".format(*self._spec) @@ -142,17 +135,6 @@ class _IndividualSpecifier(BaseSpecifier): return self._canonical_spec == other._canonical_spec - def __ne__(self, other: object) -> bool: - if isinstance(other, str): - try: - other = self.__class__(str(other)) - except InvalidSpecifier: - return NotImplemented - elif not isinstance(other, self.__class__): - return NotImplemented - - return self._spec != other._spec - def _get_operator(self, op: str) -> CallableOperator: operator_callable: CallableOperator = getattr( self, f"_compare_{self._operators[op]}" @@ -667,7 +649,7 @@ class SpecifierSet(BaseSpecifier): else "" ) - return "".format(str(self), pre) + return f"" def __str__(self) -> str: return ",".join(sorted(str(s) for s in self._specs)) @@ -706,14 +688,6 @@ class SpecifierSet(BaseSpecifier): return self._specs == other._specs - def __ne__(self, other: object) -> bool: - if isinstance(other, (str, _IndividualSpecifier)): - other = SpecifierSet(str(other)) - elif not isinstance(other, SpecifierSet): - return NotImplemented - - return self._specs != other._specs - def __len__(self) -> int: return len(self._specs) diff --git a/lib/packaging/tags.py b/lib/packaging/tags.py index 82a47cda..9a3d25a7 100644 --- a/lib/packaging/tags.py +++ b/lib/packaging/tags.py @@ -90,7 +90,7 @@ class Tag: return f"{self._interpreter}-{self._abi}-{self._platform}" def __repr__(self) -> str: - return "<{self} @ {self_id}>".format(self=self, self_id=id(self)) + return f"<{self} @ {id(self)}>" def parse_tag(tag: str) -> FrozenSet[Tag]: @@ -192,7 +192,7 @@ def cpython_tags( if not python_version: python_version = sys.version_info[:2] - interpreter = "cp{}".format(_version_nodot(python_version[:2])) + interpreter = f"cp{_version_nodot(python_version[:2])}" if abis is None: if len(python_version) > 1: @@ -207,7 +207,7 @@ def cpython_tags( except ValueError: pass - platforms = list(platforms or _platform_tags()) + platforms = list(platforms or platform_tags()) for abi in abis: for platform_ in platforms: yield Tag(interpreter, abi, platform_) @@ -251,7 +251,7 @@ def generic_tags( interpreter = "".join([interp_name, interp_version]) if abis is None: abis = _generic_abi() - platforms = list(platforms or _platform_tags()) + platforms = list(platforms or platform_tags()) abis = list(abis) if "none" not in abis: abis.append("none") @@ -268,11 +268,11 @@ def _py_interpreter_range(py_version: PythonVersion) -> Iterator[str]: all previous versions of that major version. """ if len(py_version) > 1: - yield "py{version}".format(version=_version_nodot(py_version[:2])) - yield "py{major}".format(major=py_version[0]) + yield f"py{_version_nodot(py_version[:2])}" + yield f"py{py_version[0]}" if len(py_version) > 1: for minor in range(py_version[1] - 1, -1, -1): - yield "py{version}".format(version=_version_nodot((py_version[0], minor))) + yield f"py{_version_nodot((py_version[0], minor))}" def compatible_tags( @@ -290,7 +290,7 @@ def compatible_tags( """ if not python_version: python_version = sys.version_info[:2] - platforms = list(platforms or _platform_tags()) + platforms = list(platforms or platform_tags()) for version in _py_interpreter_range(python_version): for platform_ in platforms: yield Tag(version, "none", platform_) @@ -431,7 +431,7 @@ def _generic_platforms() -> Iterator[str]: yield _normalize_string(sysconfig.get_platform()) -def _platform_tags() -> Iterator[str]: +def platform_tags() -> Iterator[str]: """ Provides the platform tags for this installation. """ @@ -481,4 +481,7 @@ def sys_tags(*, warn: bool = False) -> Iterator[Tag]: else: yield from generic_tags() - yield from compatible_tags() + if interp_name == "pp": + yield from compatible_tags(interpreter="pp3") + else: + yield from compatible_tags()