Improve type hints for pyright and ty#239
Draft
mttbernardini wants to merge 1 commit intophalt:mainfrom
Draft
Conversation
phalt
reviewed
Apr 4, 2026
Owner
phalt
left a comment
There was a problem hiding this comment.
This is a good step forward, thank you for helping to tackle it.
I've gotten very stumped trying to do this myself. I've even set some coding agents on it and struggled.
As you can see in the pull requests dependabot has been failing with ty upgrades, and part of me was just hoping it would eventually support mypy plugins.
I think your direction is a good step forward though, and I encourage you to continue!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change summary
I'm attempting to adjust the type transformations of the
Clientdecorators, so that the removal of theresultparameter can be fully expressed into the type system without relying on amypyplugin.This aims to benefit who doesn't use
mypyas their type checker (since other type checkers don't allow hooking via a plugin), to allow full type inference without having to hack# type: ignoredirectives all over the place.Pull request tasks
The following have been completed for this task:
make testmake formatmake tymake generate-test-clientsOther information
Typing for higher order functions is notoriously difficult in Python. I managed to get the typing code to correctly get inferred by
pyright, but bothmypyandtyseem to have trouble.The
mypyplugin may have to be kept ifmypycan't cope with the type hints, but because of the changes I introduced, the current plugin fails on unit tests.WIP, feedback appreciated