Skip to content

Commit

Permalink
fix: correct typing flaws exposed by 'pkginfo 1.9.4+' typing (#974)
Browse files Browse the repository at this point in the history
Closes #971.
  • Loading branch information
tseaver committed Jan 7, 2023
1 parent 05cefc0 commit 4d1737d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 0 additions & 4 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,7 +43,7 @@
".zip": "sdist",
}

MetadataValue = Union[str, Sequence[str]]
MetadataValue = Union[Optional[str], Sequence[str], Tuple[str, bytes]]

logger = logging.getLogger(__name__)

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

Expand All @@ -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,
Expand Down

0 comments on commit 4d1737d

Please sign in to comment.