Skip to content

Improve type hints for pyright and ty#239

Draft
mttbernardini wants to merge 1 commit intophalt:mainfrom
mttbernardini:fix/deprecate-mypy-plugin
Draft

Improve type hints for pyright and ty#239
mttbernardini wants to merge 1 commit intophalt:mainfrom
mttbernardini:fix/deprecate-mypy-plugin

Conversation

@mttbernardini
Copy link
Copy Markdown

Change summary

I'm attempting to adjust the type transformations of the Client decorators, so that the removal of the result parameter can be fully expressed into the type system without relying on a mypy plugin.

This aims to benefit who doesn't use mypy as their type checker (since other type checkers don't allow hooking via a plugin), to allow full type inference without having to hack # type: ignore directives all over the place.

Pull request tasks

The following have been completed for this task:

  • Code changes
  • Tests written
  • Documentation changes for new or changed features
  • Pre-review preparation
    • make test
    • make format
    • make ty
    • make generate-test-clients
      • Test clients have changed because a new feature was introduced
      • Test clients remain the same
  • Changelog updated
  • Contributors updated

Other 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 both mypy and ty seem to have trouble.

The mypy plugin may have to be kept if mypy can't cope with the type hints, but because of the changes I introduced, the current plugin fails on unit tests.

WIP, feedback appreciated

Copy link
Copy Markdown
Owner

@phalt phalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants