textual icon indicating copy to clipboard operation
textual copied to clipboard

[typing] Inconsistent typing in the work decorator

Open rodrigogiraoserrao opened this issue 10 months ago • 4 comments

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 avatar Oct 11 '23 13:10 rodrigogiraoserrao

@rodrigogiraoserrao I'm assuming this is a quick fix?

willmcgugan avatar Nov 21 '23 17:11 willmcgugan

Depends. When it comes to typing, what do we use as the ground truth? mypy, pylance, or another typechecker?

rodrigogiraoserrao avatar Nov 21 '23 17:11 rodrigogiraoserrao

Ideally we can get them to agree. If not, Mypy.

willmcgugan avatar Nov 28 '23 10:11 willmcgugan

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

rodrigogiraoserrao avatar Dec 11 '23 16:12 rodrigogiraoserrao