Skip to content
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

Add URLPattern options to django.url.conf since they were missing. #583

Merged
merged 5 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ To execute the unit tests, simply run:
pytest
```

We also test the stubs against the Django's own test suite. This is done in CI but you can also do this locally.
We also test the stubs against Django's own test suite. This is done in CI but you can also do this locally.
To execute the script run:

```bash
python ./scripts/typecheck_tests.py --django_version 3.0
python ./scripts/typecheck_tests.py --django_version 3.1
```


Expand Down
2 changes: 1 addition & 1 deletion django-stubs/conf/urls/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ handler403: Union[str, Callable[..., HttpResponse]] = ...
handler404: Union[str, Callable[..., HttpResponse]] = ...
handler500: Union[str, Callable[..., HttpResponse]] = ...

IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]]
IncludedURLConf = Tuple[List[Union[URLResolver, URLPattern]], Optional[str], Optional[str]]

def include(arg: Any, namespace: str = ..., app_name: str = ...) -> IncludedURLConf: ...
@overload
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/admin/sites.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from django.db.models.base import Model
from django.db.models.query import QuerySet
from django.http.response import HttpResponse
from django.template.response import TemplateResponse
from django.urls.resolvers import URLResolver
from django.urls import URLResolver, URLPattern
from django.utils.functional import LazyObject
from django.core.checks import CheckMessage

Expand Down Expand Up @@ -67,7 +67,7 @@ class AdminSite:
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
def get_urls(self) -> List[URLResolver]: ...
@property
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
def urls(self) -> Tuple[List[Union[URLResolver, URLPattern]], str, str]: ...
def each_context(self, request: WSGIRequest) -> Dict[str, Any]: ...
def password_change(
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/urls/conf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from .resolvers import URLResolver, URLPattern
from ..conf.urls import IncludedURLConf
from ..http.response import HttpResponseBase

def include(arg: Any, namespace: Optional[str] = ...) -> Tuple[List[URLResolver], Optional[str], Optional[str]]: ...
def include(arg: Any, namespace: Optional[str] = ...) -> Tuple[List[Union[URLResolver, URLPattern]], Optional[str], Optional[str]]: ...

# path()
@overload
Expand Down
8 changes: 8 additions & 0 deletions tests/typecheck/urls/test_conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- case: test_path_accepts_mix_of_pattern_and_resolver_output
main: |
from typing import List, Tuple, Union
from django.urls import path, URLPattern, URLResolver

def include() -> Tuple[List[Union[URLPattern, URLResolver]], None, None]: ...

path('test/', include())