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:
David Szotten
2021-07-03 11:46:29 +01:00
committed by GitHub
parent cf6952c9df
commit 739b1711a9
3 changed files with 17 additions and 7 deletions

View File

@@ -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())