From f1e3d04c065e701cc9c0ad25487b46b065be9fc0 Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Tue, 8 Oct 2024 12:54:00 +1000 Subject: [PATCH] test_support metadata: Mark data type as "optional" ``` 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. --- test_support/test_support/metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_support/test_support/metadata.py b/test_support/test_support/metadata.py index 473f32f..b90e87b 100644 --- a/test_support/test_support/metadata.py +++ b/test_support/test_support/metadata.py @@ -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", [])