-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Pylint is not smart enough when analyzes functions returning coroutine. #9745
Comments
I would argue that this is expected behaviour? We don't look at type annotations so I don't see how we could reliably do this without looking at whether |
It is used in existing code, and it is faster than async def fun():
return await another_fun() |
Why is it faster? I have never heard about this, but if it is indeed we should turn this pattern itself into a recommendation? |
from asyncio import run
from time import monotonic
from typing import Any, Coroutine
async def something() -> None:
return
async def slow_fun() -> None:
return await something()
def fast_fun() -> Coroutine[Any, Any, None]:
return something()
async def test_slow() -> None:
for i in range(1000_000):
await slow_fun()
async def test_fast() -> None:
for i in range(1000_000):
await fast_fun()
run(something()) # warm-up
a = monotonic()
run(test_fast())
b = monotonic()
print('fast', b - a)
a = monotonic()
run(test_slow())
b = monotonic()
print('slow', b - a)
|
Hmm that is interesting, I didn't know. I guess you're running into the overhead of I guess we should indeed disable the warning in this case, although it still feels like a bit of an anti-pattern. |
Bug description
Configuration
No response
Command used
Pylint output
Expected behavior
no warnings/errors
Pylint version
OS / Environment
Fedora 39
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: