-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
inheritance of asyncio.Future #12818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff from mypy_primer, showing the effect of this PR on open source code: websockets (https://github.com/aaugustin/websockets)
+ src/websockets/asyncio/connection.py:272: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/asyncio/connection.py:329: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/asyncio/connection.py:406: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/asyncio/connection.py:592: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/asyncio/connection.py:870: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/asyncio/connection.py:886: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/asyncio/server.py:484: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:624: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:777: error: Argument 1 to "shield" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:790: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:914: error: Argument 1 to "shield" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:928: error: Argument 1 to "shield" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:955: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/protocol.py:1356: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ src/websockets/legacy/server.py:813: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
tornado (https://github.com/tornadoweb/tornado)
+ tornado/test/wsgi_test.py:74: error: Need type annotation for "resps" [var-annotated]
+ tornado/test/wsgi_test.py:75: error: Argument 1 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:76: error: Argument 2 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:84: error: Need type annotation for "resps" [var-annotated]
+ tornado/test/wsgi_test.py:85: error: Argument 1 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:86: error: Argument 2 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:103: error: Need type annotation for "resps" [var-annotated]
+ tornado/test/wsgi_test.py:104: error: Argument 1 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:105: error: Argument 2 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:112: error: Need type annotation for "resps" [var-annotated]
+ tornado/test/wsgi_test.py:113: error: Argument 1 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ tornado/test/wsgi_test.py:114: error: Argument 2 to "gather" has incompatible type "Future[HTTPResponse]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/_acompat.py:90: error: Argument 1 to "shield" has incompatible type "Future[list[Any]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ psycopg_pool/psycopg_pool/_acompat.py:140: error: Argument 1 to "shield" has incompatible type "Future[list[Any]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ tests/test_pipeline_async.py:595: error: Need type annotation for "cursors" [var-annotated]
+ tests/test_pipeline_async.py:596: error: Argument 1 to "wait_for" has incompatible type "Future[list[Any]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
steam.py (https://github.com/Gobot1234/steam.py)
+ steam/gateway.py:921: error: "Never" has no attribute "__iter__" (not iterable) [attr-defined]
+ steam/gateway.py:921: error: Argument 1 to "wait_for" has incompatible type "Future[list[Never]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ steam/client.py:535: error: Argument 1 to "gather" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ steam/client.py:535: error: Argument 2 to "gather" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
python-chess (https://github.com/niklasf/python-chess)
+ chess/engine.py:1745: error: Argument 1 to "shield" has incompatible type "Future[int]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ chess/engine.py:2530: error: Argument 1 to "shield" has incompatible type "Future[int]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/verify.py: note: In function "delete_unowned_files":
+ src/bandersnatch/verify.py:106: error: Argument 1 to "gather" has incompatible type "*list[Future[None]]"; expected "Future[Never] | Generator[Any, None, Never] | Awaitable[Never]" [arg-type]
black (https://github.com/psf/black)
+ src/black/concurrency.py:188:31: error: Argument 1 to "gather" has incompatible type "*list[Future[bool]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
discord.py (https://github.com/Rapptz/discord.py)
+ discord/state.py:606: error: Argument 1 to "wait_for" has incompatible type "Future[list[Member]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ discord/state.py:1854: error: Argument 1 to "gather" has incompatible type "*dict_values[int, Task[None]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ discord/state.py:1888: error: Argument 1 to "wait_for" has incompatible type "Future[list[Member]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/broadcast_processor/broadcast_processor.py:196:35: error: Argument 1 to "gather" has incompatible type "*Set[Task[None]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/execution/execute.py:768: error: Argument 1 to "wait_for" has incompatible type "Future[None]"; expected "Future[Never] | Generator[Any, None, Never] | Awaitable[Never]" [arg-type]
paasta (https://github.com/yelp/paasta)
+ paasta_tools/instance/kubernetes.py:722: error: Argument 1 to "gather" has incompatible type "*List[Future[Dict[str, Any]]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ paasta_tools/instance/kubernetes.py:857: error: Argument 1 to "gather" has incompatible type "Task[List[Dict[Any, Any]]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ paasta_tools/instance/kubernetes.py:857: error: Argument 2 to "gather" has incompatible type "Task[List[Dict[str, Any]]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ paasta_tools/instance/kubernetes.py:1005: error: Need type annotation for "tail_lines" [var-annotated]
+ paasta_tools/instance/kubernetes.py:1005: error: Need type annotation for "previous_tail_lines" [var-annotated]
+ paasta_tools/instance/kubernetes.py:1006: error: Argument 1 to "gather" has incompatible type "Task[MutableMapping[str, Any]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ paasta_tools/instance/kubernetes.py:1007: error: Argument 2 to "gather" has incompatible type "Task[MutableMapping[str, Any]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ paasta_tools/instance/kubernetes.py:1111: error: Argument 1 to "gather" has incompatible type "*List[Future[Mapping[str, Any]]]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
+ paasta_tools/cli/cmds/mark_for_deployment.py:1888: error: Need type annotation for "coro" [var-annotated]
+ paasta_tools/cli/cmds/mark_for_deployment.py:1889: error: Argument 1 to "as_completed" has incompatible type "List[Task[Tuple[str, str]]]"; expected "Iterable[Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]]" [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/base_protocol.py:96:30: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ aiohttp/web_fileresponse.py:357:34: error: Argument 1 to "shield" has incompatible type "Future[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ aiohttp/web_protocol.py:316:42: error: Argument 1 to "shield" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/boost.py:193: error: Argument 1 to "wait_for" has incompatible type "Future[None]"; expected "Union[Future[Never], Generator[Any, None, Never], Awaitable[Never]]" [arg-type]
kopf (https://github.com/nolar/kopf)
+ kopf/_core/actions/invocation.py:139: error: Argument 1 to "shield" has incompatible type "Future[object]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ kopf/_core/reactor/queueing.py:238: error: Argument 1 to "shield" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ kopf/_core/reactor/queueing.py:245: error: Argument 1 to "shield" has incompatible type "Task[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
core (https://github.com/home-assistant/core)
+ homeassistant/helpers/trigger.py:348: error: Argument 1 to "gather" has incompatible type "*list[Task[Callable[[], None]]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ homeassistant/helpers/trigger.py:358: error: Statement is unreachable [unreachable]
+ homeassistant/helpers/trigger.py:359: error: Unused "type: ignore" comment [unused-ignore]
+ homeassistant/helpers/integration_platform.py:258: error: Argument 1 to "gather" has incompatible type "*list[Future[None]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ homeassistant/components/device_automation/__init__.py:225: error: Unused "type: ignore" comment [unused-ignore]
+ homeassistant/components/device_automation/__init__.py:225: error: Incompatible return value type (got "list[Any | BaseException]", expected "list[list[dict[str, Any]] | Exception]") [return-value]
+ homeassistant/components/device_automation/__init__.py:225: note: Error code "return-value" not covered by "type: ignore" comment
+ homeassistant/helpers/entity_platform.py:373: error: Argument 1 to "gather" has incompatible type "*list[Task[None]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ homeassistant/components/google_assistant/smart_home.py:254: error: Need type annotation for "execute_results" [var-annotated]
+ homeassistant/components/google_assistant/smart_home.py:256: error: Argument 1 to "shield" has incompatible type "Future[list[Any]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ homeassistant/bootstrap.py:907: error: Argument 1 to "gather" has incompatible type "*list[Task[bool]]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
|
From the mypy-primer results this seems to be doing bad things to mypy's type inference. |
Very much so! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Awaitable
is definitely unneeded.Iterable
is a little weird because it'sIterable[_T]
, which impliesdef __iter__(self) -> Iterator[_T_co]: ...
. We havedef __iter__(self) -> Generator[Any, None, _T]: ...
instead, andGenerator[_YieldT_co, _SendT_contra, _ReturnT_co]
isIterator[_YieldT_co]
notIterator[_ReturnT_co]
. So I'm a little unsure about that one.