Skip to content

Commit

Permalink
Simplify metadata typing
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrutledge committed Apr 26, 2020
1 parent 4879261 commit 70caa87
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
3 changes: 1 addition & 2 deletions twine/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from typing import IO
from typing import List
from typing import Tuple
from typing import cast

import readme_renderer.rst

Expand Down Expand Up @@ -89,7 +88,7 @@ def _check_file(
)
description_content_type = "text/x-rst"

content_type, params = cgi.parse_header(cast(str, description_content_type))
content_type, params = cgi.parse_header(description_content_type)
renderer = _RENDERERS.get(content_type, _RENDERERS[None])

if description in {None, "UNKNOWN\n\n\n"}:
Expand Down
8 changes: 2 additions & 6 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
import io
import os
import subprocess
from typing import IO
from typing import Any
from typing import Dict
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import Union

import pkg_resources
import pkginfo
Expand All @@ -46,8 +44,6 @@
".zip": "sdist",
}

MetadataValue = Union[str, Sequence[str], Tuple[str, IO, str]]


class PackageFile:
def __init__(
Expand Down Expand Up @@ -110,7 +106,7 @@ def from_filename(cls, filename: str, comment: Optional[str]) -> "PackageFile":

return cls(filename, comment, meta, py_version, dtype)

def metadata_dictionary(self) -> Dict[str, MetadataValue]:
def metadata_dictionary(self) -> Dict[str, Any]:
meta = self.metadata
data = {
# identify release
Expand Down
4 changes: 1 addition & 3 deletions twine/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def close(self) -> None:
self.session.close()

@staticmethod
def _convert_data_to_list_of_tuples(
data: Dict[str, package_file.MetadataValue]
) -> List[Tuple[str, package_file.MetadataValue]]:
def _convert_data_to_list_of_tuples(data: Dict[str, Any]) -> List[Tuple[str, Any]]:
data_to_send = []
for key, value in data.items():
if key in KEYWORDS_TO_NOT_FLATTEN or not isinstance(value, (list, tuple)):
Expand Down

0 comments on commit 70caa87

Please sign in to comment.