forked from typeddjango/django-stubs
-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
I'm thinking about how to get it right.
Currently our lazy functions just returning str
, and I think about changing that to class StrPromise(Promise, str): ...
There's some problems with that, but it's better than plain str, and least disruptive. E.q. we don't need to change much code.
- Return Promise for lazy functions. typeddjango/django-stubs#689 (comment)
- Broaden type annotation for verbose_name(_plural) to accept lazystr. typeddjango/django-stubs#1139 (comment)
It allows us to catch places where we expect StrPromise, but getting str.
class Promise: ...
class StrPromise(Promise, str): ...
def gettext_lazy(v: str) -> StrPromise: ...
v1: StrPromise = StrPromise()
# Error
v2: StrPromise = ""
# Both cases ok
v3: str = ""
v4: str = StrPromise()
@sbdchd what do you think?
Metadata
Metadata
Assignees
Labels
No labels