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
* Revert "fix referencing `.value` of a Choices variable (#2644)"
This reverts commit 7b4145d.
* Add `__init__.py` files to `tests/assert_type/` tree
Without these we cannot import from other modules properly which is
useful for testing the behaviour of resolving types in the plugin.
* Add comments to assertions for choices tests
Add some comments to explain what is being tested in each block of
`assert_type()` calls.
* Fix type resolution for choices in plugin (1)
The resolution of the attribute type was too naive and didn't handle
where a module is imported and the choices type is accessed as an
attribute from that module.
Eliminates 11,087 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
Co-authored-by: Stephen Moore <[email protected]>
* Fix type resolution for choices in plugin (2)
The resolution of the attribute type was too naive and didn't handle
where a choices type is aliased and then used via that alias.
Eliminates 53 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
Co-authored-by: Stephen Moore <[email protected]>
* Fix type resolution for choices in plugin (3)
The resolution of the attribute type was too naive and didn't handle
where a choices type is aliased by type and then used via that alias.
Eliminates 37 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
Co-authored-by: Stephen Moore <[email protected]>
* Fix type resolution for choices in plugin (4)
The resolution of the attribute type was too naive and didn't handle
where a choices type is bound in a type variable.
Eliminates 10 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
Co-authored-by: Stephen Moore <[email protected]>
* Fix type resolution for choices in plugin (5)
The resolution of the attribute type was too naive and didn't handle
where a choices type is decomposed to a union of enum literals when a
comparison to a member is made in a branch.
Eliminates 33 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
Co-authored-by: Stephen Moore <[email protected]>
* Fix type resolution for choices in plugin (6)
The resolution of the attribute type was too naive and didn't handle
where a choices type overrides a property, e.g. label, and makes use
of `super()`.
Eliminates 1 error in a large repository that was raised when upgrading
from django-stubs v5.1.3 to v5.2.0 which included the changes in
a3f2a55.
* Fix type resolution for choices in plugin (7)
The resolution of the attribute type was too naive and didn't handle
where a choices type is decomposed to a single enum literal when a
comparison to a member is made in a branch.
Eliminates 1 error in a large repository that was raised when upgrading
from django-stubs v5.1.3 to v5.2.0 which included the changes in
a3f2a55.
* Restructure value replacement in choices plugin
Ahead of a future commit that alters handling of labels, perform this
simplification.
* Add non-lazy label handling for choices in plugin
Because of the change to use `django.utils.functional._StrOrPromise` for
labels to improve accuracy, it can be a little painful - especially in
a very large codebase where translations / lazy strings are not used.
This change keeps the stubs unchanged for correctness, e.g. in pyright
for where there is no alternative, but tweaks the mypy plugin to handle
introspecting the members to determine whether there are no lazy strings
such that the types can be narrowed.
Eliminates 1,166 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
* Suppress some errors in choices plugin
This case is a little complex as we have a mix of choices types. In
theory we could handle this, but it would require more rework to handle
multiple types. For now, just make no changes and return the original
type.
Eliminates 11 errors in a large repository that were raised when
upgrading from django-stubs v5.1.3 to v5.2.0 which included the changes
in a3f2a55.
---------
Co-authored-by: Stephen Moore <[email protected]>
0 commit comments