-
-
Notifications
You must be signed in to change notification settings - Fork 516
Open
Description
Hi there! First of all, thank you for creating django-stubs - I'm a maintainer of a type checker called pyrefly, and we've been building support for django on top of django-stubs.
I had a question about some of the asserted types in tests/assert_type/db/models/test_enums.py. The gettext_lazy function is annotated as returning _StrPromise, but calls to gettext_lazy have asserted types of _StrOrPromise, e.g.:
class Suit(IntegerChoices):
DIAMOND = 1, _("Diamond")
SPADE = 2, _("Spade")
HEART = 3, _("Heart")
CLUB = 4, _("Club")
assert_type(Suit.CLUB.label, _StrOrPromise) # why is this not _StrPromise?
class Vehicle(IntegerChoices):
CAR = 1, "Carriage"
TRUCK = 2
JET_SKI = 3
__empty__ = _("(Unknown)")
assert_type(Vehicle.__empty__, _StrOrPromise) # why is this not _StrPromise?
Is there some Django magic I'm not aware of that is widening these types? Or is mypy inferring types that are less precise than they could be?
I'm pretty unfamiliar with Django, so apologies if this is a silly question. Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels