diff --git a/mypy.ini b/mypy.ini index dddd808b..0c09ee80 100644 --- a/mypy.ini +++ b/mypy.ini @@ -18,10 +18,6 @@ warn_return_any = True no_implicit_reexport = True strict_equality = True -[mypy-pkginfo] -; https://bugs.launchpad.net/pkginfo/+bug/1876591 -ignore_missing_imports = True - [mypy-requests_toolbelt,requests_toolbelt.*] ; https://github.com/requests/toolbelt/issues/279 ignore_missing_imports = True diff --git a/setup.cfg b/setup.cfg index c8e59629..7308cecf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ packages = twine.commands python_requires = >=3.7 install_requires= - pkginfo >= 1.8.1, < 1.9.3 # https://github.com/pypa/twine/issues/971 + pkginfo >= 1.8.1 readme-renderer >= 35.0 requests >= 2.20 requests-toolbelt >= 0.8.0, != 0.9.0 diff --git a/twine/package.py b/twine/package.py index 3ca074fe..5c101033 100644 --- a/twine/package.py +++ b/twine/package.py @@ -17,7 +17,7 @@ import os import re import subprocess -from typing import Dict, NamedTuple, Optional, Sequence, Tuple, Union +from typing import Dict, NamedTuple, Optional, Sequence, Tuple, Union, cast import importlib_metadata import pkginfo @@ -43,7 +43,7 @@ ".zip": "sdist", } -MetadataValue = Union[str, Sequence[str]] +MetadataValue = Union[Optional[str], Sequence[str], Tuple[str, bytes]] logger = logging.getLogger(__name__) @@ -129,9 +129,9 @@ def from_filename(cls, filename: str, comment: Optional[str]) -> "PackageFile": ) py_version = dist.metadata["Version"] elif dtype == "bdist_wheel": - py_version = meta.py_version + py_version = cast(wheel.Wheel, meta).py_version elif dtype == "bdist_wininst": - py_version = meta.py_version + py_version = cast(wininst.WinInst, meta).py_version else: py_version = None @@ -143,7 +143,7 @@ def metadata_dictionary(self) -> Dict[str, MetadataValue]: Includes values from filename, PKG-INFO, hashers, and signature. """ meta = self.metadata - data = { + data: Dict[str, MetadataValue] = { # identify release "name": self.safe_name, "version": meta.version,