Skip to content

Disambiguate generics with unknown parametric assignments #492

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

Merged
merged 2 commits into from
May 2, 2025

Conversation

JordonPhillips
Copy link
Contributor

Pyright's strict mode is becoming increasingly strict with regards to generics. You used to be able to effectively narrow them by declaring the type like so:

string_list: list[str] = list()

But that's no longer accepted. Now the actual value must itself resolve to something that has resolved parameterization. This unfortunately means that actual casting is sometimes necessary. It's not a huge hit because it's a do-nothing function, but it's still a function call that I'd rather not be doing.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@JordonPhillips JordonPhillips marked this pull request as ready for review May 2, 2025 14:21
@JordonPhillips JordonPhillips requested a review from a team as a code owner May 2, 2025 14:21
Pyright's strict mode is becoming increasingly strict with regards
to generics. You used to be able to effectively narrow them by
declaring the type like so:

string_list: list[str] = list()

But that's no longer accepted. Now the actual value must itself
resolve to something that has resolved parameterization. This
unfortunately means that actual casting is sometimes necessary.
It's not a huge hit because it's a do-nothing function, but it's
still a function call that I'd rather not be doing.
Copy link
Contributor

@jonathan343 jonathan343 left a comment

Choose a reason for hiding this comment

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

LGTM!

@JordonPhillips JordonPhillips merged commit 6a85f06 into develop May 2, 2025
2 checks passed
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