Skip to content

Commit

Permalink
test_support metadata: Mark data type as "optional"
Browse files Browse the repository at this point in the history
```
test_support/test_support/metadata.py:274: error: Argument 10 to "StandardMetadata" has incompatible type "list[tuple[str, str]]"; expected "list[tuple[str, str | None]]"  [arg-type]
test_support/test_support/metadata.py:274: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
test_support/test_support/metadata.py:274: note: Consider using "Sequence" instead, which is covariant
test_support/test_support/metadata.py:275: error: Argument 11 to "StandardMetadata" has incompatible type "list[tuple[str, str]]"; expected "list[tuple[str, str | None]]"  [arg-type]
test_support/test_support/metadata.py:275: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
test_support/test_support/metadata.py:275: note: Consider using "Sequence" instead, which is covariant
```

Not sure if `str | None` is valid in all Python versions we support, but
I think `Optional[str]` and `Union[str, None]` if I'm not mistaken, more
or less say the same thing.  So let's go with the most concise and
widely supported of these.
  • Loading branch information
sjlongland committed Oct 8, 2024
1 parent 0863153 commit f1e3d04
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test_support/test_support/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def is_at_least(required: str, *, v=metadata_version):

authors = _parse_contributors("Author", get("Author", []), "Author-email", get("Author-email", []))

maintainers: List[Tuple[str, str]]
maintainers: List[Tuple[str, Optional[str]]]
if is_at_least("1.2"):
maintainers = _parse_contributors(
"Maintainer", get("Maintainer", []), "Maintainer-email", get("Maintainer-email", [])
Expand Down

0 comments on commit f1e3d04

Please sign in to comment.