-
Notifications
You must be signed in to change notification settings - Fork 815
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
Fix decorator typing issue. #3862
Conversation
Callable[DecoratorParamSpec, Coroutine[None, None, ReturnType]], | ||
Callable[DecoratorParamSpec, Coroutine[Any, Any, ReturnType]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coroutines like async def foo() -> T: ...
have their type inferred as Coroutine[Any, Any, T]
, so I swapped all of the Coroutine[None, None, T]
for Coroutine[Any, Any, T]
under the assumption that the usage of None
was a mistake.
Is it possible to get a concise explanation/example of what this addresses? I've followed the reference chain here but there's a lot of discussion and it's not clear to me what this finally changes and why. For example:
As I look at |
Running textual/src/textual/_work_decorator.py Line 74 in 03fb1b1
Additionally, in the signature of the concrete definition of textual/src/textual/_work_decorator.py Lines 78 to 89 in 03fb1b1
Pylance complains that
On top of this, typing in places where this decorator is used gets screwed up because inference breaks. |
@willmcgugan Feel free to take a look when you're ready. Might be worth considering #3937 as well. |
@rodrigogiraoserrao I don't think we can accept this if it causes other others. Are the other errors a direct consequence of this change, and could they be fixes relatively easily? |
They are direct consequences. |
@willmcgugan like I mentioned previously, this seems to be the issue and Pylance is happy about it but mypy complains in other places about the changes I made.
In particular, running mypy (both 1.7.1 and
1.9.0+dev.0567da99784c376e723907daf4f16df2f03368c1 0567da9
) in our codebase introduces these type errors:new mypy errors
It does get rid of the errors in
_work_decorator.py
, both for mypy and pylance.I'll leave it up to you if we want to roll with these changes, mark this as draft, or just reject the PR.
Extra context:
Fixes #3510 .