Error handling for recursive TypeVar defaults (PEP 696)#16925
Merged
JelleZijlstra merged 3 commits intopython:masterfrom Feb 20, 2024
Merged
Error handling for recursive TypeVar defaults (PEP 696)#16925JelleZijlstra merged 3 commits intopython:masterfrom
JelleZijlstra merged 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Member
|
Seems like psycopg found the NotImplementedError for you... It's a TypeAlias generic over a TypeVar with both a bound and a default: |
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
Yeah. It's really helpful to get that feedback immediately. Anyway, it was a simple fix. The TypeAliasType is already evaluated earlier, so there is no need to travers it. Just returning the type unchanged is enough. |
JelleZijlstra
approved these changes
Feb 19, 2024
Member
JelleZijlstra
left a comment
There was a problem hiding this comment.
Thanks! Noticed a typo; I'll fix that and merge.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
hamdanal
pushed a commit
to hamdanal/mypy
that referenced
this pull request
Feb 20, 2024
This PR adds some additional error handling for recursive TypeVar defaults. Open issue for future PRs: - Expanding nested recursive defaults, e.g. `T2 = list[T1 = str]` - Scope binding, especially for TypeAliasTypes Ref: python#14851
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.
This PR adds some additional error handling for recursive TypeVar defaults.
Open issue for future PRs:
T2 = list[T1 = str]Figure out ifvisit_type_alias_typefor theTypeVarDefaultTranslatorvisitor is actually needed. The base class does not provide a default implementation. So far I haven't hit theNotImplementedError.Ref: #14851