Skip to content
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

refactor: Use Parameter class directly in type hints instead of _Parameter protocol #3405

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

binste
Copy link
Contributor

@binste binste commented Apr 14, 2024

Turns out I was wrong in #3208 (comment) which is nice in this case :) We can use the Parameter class directly in type hints without running into circular imports thanks to typing.TYPE_CHECKING. See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#import-cycles for more details but in summary, type checkers can be much more flexible how they import stuff as they don't run actual code so they can also deal with circular imports.

There is no impact for users except that instead of _Parameter as type hints:

image

they now see the less confusing Parameter:
image

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.

None yet

1 participant