-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Precise annotation for _field_types
ClassVar
#14241
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
Conversation
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This is incorrect, |
I apologize for my hubris. I'll open an issue.
(peace) سلام, 和谐 (group harmony), health, and happiness,
Hunter
Sent from Proton Mail Android
…-------- Original Message --------
On 6/8/25 8:01 AM, Jelle Zijlstra wrote:
JelleZijlstra left a comment [(python/typeshed#14241)](#14241 (comment))
This is incorrect, _field_types doesn't hold any of those types.
—
Reply to this email directly, [view it on GitHub](#14241 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAWSIU77VSWISG6CV4L3KZL3CQXZVAVCNFSM6AAAAAB62TRWU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJUGA3DANJQGM).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Issue created #14245
"those types": _ConstantValue | AST | list[AST] | list[str] True, the annotation is not precise, and it may be incorrect, but >>> ast.Global._field_types
{'names': list[str]}
>>> ast.Nonlocal._field_types
{'names': list[str]}
>>> ast.MatchClass._field_types['kwd_attrs']
list[str] I sincerely don't know how to evaluate your claim that I omitted some types from the annotation because I believed they were represented by
|
The dictionary contains the value The correct annotation for this field is arguably |
I did not see that coming. I just reread the ClassVar documentation. Despite now knowing the above is true, I can't decipher the documentation. Thank you for the explanation. |
This is nothing to do with ClassVar, it's how all type annotations work. |
Hmm. I suspect I have a significant defect in my mental model of type annotations. Oh no, I hope my mental model isn't flawed because I don't understand OOP despite 30+ years of exposure to OOP. 😨 |
Refine the type annotation for
_field_types
to a more specific union of types, enhancing type safety and clarity in the codebase.