Skip to content
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

Do not wrap AsyncIterator and Coroutine with extra Coroutine in async functions #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sterliakov
Copy link
Owner

Copy link

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

steam.py (https://github.com/Gobot1234/steam.py)
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 1  [misc]
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 2  [misc]

jinja (https://github.com/pallets/jinja)
+ src/jinja2/filters.py:1520: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ src/jinja2/filters.py:1571: error: "return" with value in async generator is not allowed  [misc]
+ src/jinja2/filters.py:1607: error: "return" with value in async generator is not allowed  [misc]
+ src/jinja2/filters.py:1647: error: "return" with value in async generator is not allowed  [misc]
+ src/jinja2/filters.py:1685: error: "return" with value in async generator is not allowed  [misc]

websockets (https://github.com/aaugustin/websockets)
+ src/websockets/legacy/protocol.py:1264: error: Incompatible types in "await" (actual type "float", expected type "Awaitable[Any]")  [misc]

starlette (https://github.com/encode/starlette)
+ tests/middleware/test_gzip.py:70: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ tests/middleware/test_gzip.py:75: error: Argument 1 to "StreamingResponse" has incompatible type "Coroutine[Any, Any, Union[AsyncIterable[Union[str, bytes, memoryview]], Iterable[Union[str, bytes, memoryview]]]]"; expected "Union[AsyncIterable[Union[str, bytes, memoryview]], Iterable[Union[str, bytes, memoryview]]]"  [arg-type]
+ tests/middleware/test_gzip.py:75: note: Maybe you forgot to use "await"?
+ tests/middleware/test_gzip.py:94: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ tests/middleware/test_gzip.py:100: error: Argument 1 to "StreamingResponse" has incompatible type "Coroutine[Any, Any, Union[AsyncIterable[Union[str, bytes, memoryview]], Iterable[Union[str, bytes, memoryview]]]]"; expected "Union[AsyncIterable[Union[str, bytes, memoryview]], Iterable[Union[str, bytes, memoryview]]]"  [arg-type]
+ tests/middleware/test_gzip.py:100: note: Maybe you forgot to use "await"?

trio (https://github.com/python-trio/trio)
+ src/trio/_tests/test_util.py:150: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/defer.py:344: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/spiders/crawl.py:166: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/core/spidermw.py:129: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/core/spidermw.py:146: error: Incompatible return value type (got "Coroutine[Any, Any, AsyncIterable[_T]]", expected "Iterable[_T] | AsyncIterable[_T]")  [return-value]
+ scrapy/core/spidermw.py:146: note: Maybe you forgot to use "await"?
+ scrapy/core/scraper.py:284: error: Incompatible types in assignment (expression has type "Coroutine[Any, Any, AsyncIterable[_T]]", variable has type "Iterable[_T] | AsyncIterable[_T]")  [assignment]
+ scrapy/core/scraper.py:284: note: Maybe you forgot to use "await"?
+ scrapy/core/scraper.py:288: error: Argument 1 to "parallel_async" has incompatible type "Iterable[_T] | AsyncIterable[_T]"; expected "AsyncIterable[Any]"  [arg-type]
+ scrapy/spidermiddlewares/urllength.py:42: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/spidermiddlewares/referer.py:393: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/spidermiddlewares/offsite.py:52: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/spidermiddlewares/depth.py:54: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes  [misc]
+ scrapy/commands/parse.py:159: error: Argument 1 to "collect_asyncgen" has incompatible type "Coroutine[Any, Any, AsyncIterable[Any]]"; expected "AsyncIterable[Never]"  [arg-type]
+ scrapy/commands/parse.py:159: note: Maybe you forgot to use "await"?

discord.py (https://github.com/Rapptz/discord.py)
+ discord/state.py:601: error: Argument 1 to "wait_for" has incompatible type "list[Member]"; expected "Future[Never] | Generator[Any, None, Never] | Awaitable[Never]"  [arg-type]
+ discord/state.py:1234: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
+ discord/state.py:1797: error: Argument 1 to "wait_for" has incompatible type "list[Member]"; expected "Future[Never] | Generator[Any, None, Never] | Awaitable[Never]"  [arg-type]

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