Open albertjan opened 1 year ago
First, note that pyright
is not officially supported by TypedDjango project although we're open to improvements that help other type checkers.
Note that path()
is an overloaded function with multiple signatures: https://github.com/typeddjango/django-stubs/blob/82c394fbdc1461d0d483162577fac50e9cacd605/django-stubs/urls/conf.pyi#L18-L28
It's weird that pyright singles out one of the multiple signatures in its error message.
The first signature with view: Callable[..., HttpResponseBase]
should match AsView[GenericView]
, because AsView.__call__
is defined as the _View
typevar, which in this case is GenericView
.
And GenericView
's __call__
signature def __call__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> Response
should be compatible with the callable.
This works in my projects with mypy. If you figure out why pyright doesn't agree with this chain of reasoning, we might be able to come up with a fix or work-around.
Thanks! I'll investigate a little more. 😊
This has been my main issue in adopting drf stubs, this getting fixed would be great 😊
Bug report
What's wrong
For this line:
path("auth-test/", apitest.AuthTest.as_view()),
we get the following type error:
How is that should be
Since it works the types should also be compatible right?!
System information
python
version: Python 3.11.6django
version: 4.2.7pyright
version: pyright 1.1.336django-stubs
version: