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 27, 2020
1 parent 4879261 commit ebd2ada
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions twine/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ def _check_file(
package = package_file.PackageFile.from_filename(filename, comment=None)

metadata = package.metadata_dictionary()
description = metadata["description"]
description_content_type = metadata["description_content_type"]
description = cast(str, metadata["description"])
description_content_type = cast(str, metadata["description_content_type"])

if description_content_type is None:
warnings.append(
"`long_description_content_type` missing. defaulting to `text/x-rst`."
)
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
3 changes: 1 addition & 2 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io
import os
import subprocess
from typing import IO
from typing import Dict
from typing import Optional
from typing import Sequence
Expand Down Expand Up @@ -46,7 +45,7 @@
".zip": "sdist",
}

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


class PackageFile:
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 ebd2ada

Please sign in to comment.