You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend AttributeError suggestions to type-object (static and enum) misses
A missing attribute on a reflected type object -- a mistyped static member or
enum value such as DayOfWeek.Sundey -- previously raised the bare CPython
"type object 'X' has no attribute 'Y'" with no hint, because the miss hook was
installed on reflected types (governing their instances) but type-object access
is governed by the CLR metatype.
Install the same miss-only __getattr__ hook on the CLR metatype (allowing the
redirect when tp_getattro is type_getattro, not just the generic getattr), so a
type-object miss is enriched the same way instance misses are. BuildMissing
AttributeMessage now resolves the target from either a CLRObject (instance) or a
ClassBase (type object) and uses CPython's "type object 'T'" wording for the
latter.
Suggestions reuse the existing ranking/cache and the snake_case convention
Python exposes members under (ToSnakeCaseMemberName): methods become lower_snake
while enum values, consts and static-readonly members become UPPER_SNAKE, e.g.
DayOfWeek.Sundey -> "Did you mean: 'SUNDAY'?", Math.PII -> 'PI', String.Empy ->
'EMPTY'. All suggested names resolve. Hits, imports and hasattr on type objects
are unaffected (the hook is miss-only).
Adds tests for enum, static const, static-readonly field and static method
misses, the no-similar case and hasattr, in test_enum.py and test_class.py.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments