mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-20 02:41:16 +08:00
Use Sequence instead of List for path param (#659)
Unlike `List`, which is invariant, `Sequence` is covariant, which lets `path` accept lists of subsets of the `Union` as well. I believe this is safe, as django doesn't mutate this input. I found [this comment](https://github.com/python/mypy/issues/3351#issuecomment-300447832) helpful
This commit is contained in:
@@ -6,3 +6,13 @@
|
||||
def include() -> Tuple[List[Union[URLPattern, URLResolver]], None, None]: ...
|
||||
|
||||
path('test/', include())
|
||||
|
||||
|
||||
- case: test_path_accepts_pattern_resolver_union_subset
|
||||
main: |
|
||||
from typing import List, Tuple
|
||||
from django.urls import path, URLPattern
|
||||
|
||||
def include() -> Tuple[List[URLPattern], None, None]: ...
|
||||
|
||||
path('test/', include())
|
||||
|
||||
Reference in New Issue
Block a user