-
-
Notifications
You must be signed in to change notification settings - Fork 511
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm experimenting with type annotations and chose a fairly simple project to add type annotations to (just a couple of additional Django checks). However I ran into the following:
What's wrong
from django.core.checks import register
@register("foo")
def check_foo_is_bar(app_configs: Apps, **kwargs: Any) -> List[Warning]:
...
Results in mypy complaining:
Untyped decorator makes function "check_foo_is_bar" untyped
How it should be
The register decorator is currently annotated as returning Any
. If somehow it can be annotated as being essentially the same as CheckRegistry.register
all would be well (I think). Is that possible?
System information
python
version: Python 3.8.12django
version: 4.1mypy
version: 0.961django-stubs
version: 1.12.0django-stubs-ext
version: 0.5.0
Additional information
It's possible to work around this by using the decorator as a function instead:
def check_foo_is_bar(app_configs: Apps, **kwargs: Any) -> List[Warning]:
...
register(check_foo_is_bar, "foo")
But it would be nice if the decorator worked as well.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working