Skip to content

Use tagged union for getaddrinfo()#16010

Open
Dreamsorcerer wants to merge 4 commits into
python:mainfrom
Dreamsorcerer:getaddrinfo-tagged-union
Open

Use tagged union for getaddrinfo()#16010
Dreamsorcerer wants to merge 4 commits into
python:mainfrom
Dreamsorcerer:getaddrinfo-tagged-union

Conversation

@Dreamsorcerer

Copy link
Copy Markdown
Contributor

Fixes our regression: #15788 (comment)
Should also fix the pre-existing ignore too.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

urllib3 (https://github.com/urllib3/urllib3)
+ test/contrib/test_socks.py:120: error: Incompatible return value type (got "list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]", expected "list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]")  [return-value]
+ test/contrib/test_socks.py:120: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ test/contrib/test_socks.py:120: note: Consider using "Sequence" instead, which is covariant

trio (https://github.com/python-trio/trio)
+ src/trio/_socket.py:218: error: Incompatible return value type (got "list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]", expected "list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]")  [return-value]
+ src/trio/_socket.py:218: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ src/trio/_socket.py:218: note: Consider using "Sequence" instead, which is covariant
+ src/trio/_socket.py:247: error: Argument 1 to "to_thread_run_sync" has incompatible type "Callable[[bytes | str | None, bytes | str | int | None, int, int, int, int], list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]]"; expected "Callable[[bytes | None, bytes | str | int | None, int, int, int, int], list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]]"  [arg-type]
+ src/trio/_tests/test_socket.py:128: error: Argument 1 to "MonkeypatchedGAI" has incompatible type "Callable[[bytes | str | None, bytes | str | int | None, int, int, int, int], list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]]"; expected "Callable[[str | bytes | None, str | bytes | int | None, int, int, int, int], list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]]"  [arg-type]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/synchronous/helpers.py:135: error: Incompatible return value type (got "list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]", expected "list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]")  [return-value]
+ pymongo/synchronous/helpers.py:135: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ pymongo/synchronous/helpers.py:135: note: Consider using "Sequence" instead, which is covariant
+ pymongo/asynchronous/helpers.py:135: error: Incompatible return value type (got "list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]", expected "list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]")  [return-value]
+ pymongo/asynchronous/helpers.py:135: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
+ pymongo/asynchronous/helpers.py:135: note: Consider using "Sequence" instead, which is covariant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant