Skip to content

Commit

Permalink
Fix urlpatterns use Sequence instead of List (#19)
Browse files Browse the repository at this point in the history
Use `Sequence` instead of `List` in `apply_suffix_patterns` and `format_suffix_patterns`. This thread, python/mypy#3351 (comment), explains why `List`, which is invariant, isn't suitable here
  • Loading branch information
kylebebak authored Apr 12, 2022
1 parent 81b0175 commit d17362e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rest_framework-stubs/urlpatterns.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from typing import List, Optional, Pattern, Union
from typing import List, Optional, Pattern, Sequence, Union

from django.urls.resolvers import RoutePattern, URLPattern, URLResolver

def apply_suffix_patterns(
urlpatterns: List[Union[URLResolver, RoutePattern, URLPattern, Pattern[str]]],
urlpatterns: Sequence[Union[URLResolver, RoutePattern, URLPattern, Pattern[str]]],
suffix_pattern: Union[str, Pattern[str]],
suffix_required: bool,
suffix_route: Optional[str] = ...,
) -> List[URLPattern]: ...
def format_suffix_patterns(
urlpatterns: List[Union[URLResolver, RoutePattern, URLPattern, Pattern[str]]],
urlpatterns: Sequence[Union[URLResolver, RoutePattern, URLPattern, Pattern[str]]],
suffix_required: bool = ...,
allowed: Optional[List[Union[URLPattern, Pattern[str], str]]] = ...,
) -> List[URLPattern]: ...

0 comments on commit d17362e

Please sign in to comment.