-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format_suffix_patterns should have covariant type for urlpatterns parameter #184
Labels
bug
Something isn't working
Comments
PRs are welcome! |
I guess the same is happening when you try to add from django.urls import path
from rest_framework.routers import DefaultRouter
urlpatterns = [
path(route="one/", view=OneView.as_view(), name="some-view"),
...
]
router = DefaultRouter()
router.register(prefix="two", viewset=views.TwoViewSet, basename="two")
urlpatterns += router.urls
Argument 1 to "__iadd__" of "list" has incompatible type "List[Union[URLPattern, URLResolver]]"; expected "Iterable[URLPattern]" [arg-type] Or it is completely different issue? |
Different issue. Mypy infers the type of your local variable urlpatterns = [
path(route="one/", view=OneView.as_view(), name="some-view"),
...
] It infers it as Give it a type when you declare it that supports urlpatterns: list[URLPattern, URLResolver] = [
path(route="one/", view=OneView.as_view(), name="some-view"),
...
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version 1.4.0 of DRF-stubs and Following along with the DRF tutorial I've got the following pattern (mypy output inline in comments):
Looking at the source for
format_suffix_patterns()
andapply_suffix_patterns()
they only iterate over the contents of theurlpatterns
input, nothing specific to it being alist
.Can we change the
urlpatterns
parameter fromList
toIterable
?System information
python
version: 3.10.1django
version: 4.0.1mypy
version: 0.931django-stubs
version: 0.3.1The text was updated successfully, but these errors were encountered: