Uh oh!
There was an error while loading. Please reload this page.
Allow errors for unsound Self definitions on non-final classes - #2221
Merged
JelleZijlstra merged 9 commits intoApr 2, 2026
Merged
Conversation
davidhalter
commented
Mar 30, 2026
CollaboratorAuthor
@JelleZijlstra Would you mind reviewing this? IMO it's a very uncontroversial change. The problem is (quoting from discuss): There is currently no part of the spec that describes this. |
carljm
reviewed
Mar 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
…iables are accessed
davidhalterforce-pushed
the
allow-unsound-error-self-classvar
branch
from
March 30, 2026 19:47
2f2b8d1 to
ac4622fComparecarljm
approved these changes
Mar 30, 2026
| TypeForm[Any] is not considered equivalent to itself. | ||
| """ | ||
| conformance_automated = "Fail" | ||
| conformance_automated = "Pass" |
There was a problem hiding this comment.
I'd prefer to keep this in a separate PR now that we allow fixing type checker versions, I can prepare a PR now to update it though.
CollaboratorAuthor
There was a problem hiding this comment.
Makes sense, I'll try to revert it.
CollaboratorAuthor
There was a problem hiding this comment.
Zuban is now at the same version as before and the results are much more understandable
JelleZijlstra
approved these changes
Mar 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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 comes after #2148 which wants to make this a mandatory error.
But for now it should be totally fine to allow type checkers to error here, since it can clearly be shown to be unsound, see also:
https://discuss.python.org/t/disallow-access-to-class-variables-with-self/105434
I'm happy to revisit the original pull request, but for now I hope this should suffice. I will rerun the automated tests if and once no changes are required.