textual
textual copied to clipboard
[typing] Inconsistent typing in the work decorator
See this discussion about the usage of Decorator
versus Decorator[..., ReturnType]
in src/textual/_work_decorator.py
.
EDIT: Last time I tackled this (and opened PR #3862) I ended up hitting what looked like a mypy issue but might as well just be something I didn't get right. I did try to outsource the fix to Twitter and a Discord server but no one was able to help me. Independently from me, PR #3937 does similar work that would also fix this issue.
@rodrigogiraoserrao I'm assuming this is a quick fix?
Depends. When it comes to typing, what do we use as the ground truth? mypy, pylance, or another typechecker?
Ideally we can get them to agree. If not, Mypy.
I was exploring a fix to the typing issues that then triggered new typing issues in other places of the codebase where the decorator work
is used.
Work on this surfaced a possible mypy bug. I've created a standalone gist which seems to contain this possible bug: https://mypy-play.net/?mypy=latest&python=3.12&gist=c451dedbb5ec867b98fcfec6aa24d698 I also asked for help on Twitter: https://twitter.com/mathsppblog/status/1734247854854599035