django-stubs
django-stubs copied to clipboard
Replace TypeAlias `_ClassLevelWidgetT` with descriptor `_WidgetTypeOrInstance`
I have made things!
Related issues
None I could find.
This change allows for recognizing when .widget is used on Field instance and when on the type itself, allowing for different type annotations in each case.
Why even bother?
Example: Currently this correct code does not recognize is_required and attrs on field.widget, because it might be a type and not an instance.
After the change all types are correctly inferred, and syntax highlighting works as expected:
I hope you find it worth adding.