Skip to content

Commit 5f6b4bf

Browse files
committed
add test_views test folder
1 parent d03fddd commit 5f6b4bf

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

django-stubs/shortcuts.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Dict, List, Optional, Type, Union
1+
from typing import Any, Callable, Dict, List, Optional, Type, Union, Sequence
22

33
from django.db.models import Manager, QuerySet
44
from django.db.models.base import Model
@@ -15,7 +15,7 @@ def render_to_response(
1515
) -> HttpResponse: ...
1616
def render(
1717
request: HttpRequest,
18-
template_name: str,
18+
template_name: Union[str, Sequence[str]],
1919
context: Optional[Dict[str, Any]] = ...,
2020
content_type: Optional[str] = ...,
2121
status: Optional[int] = ...,

django-stubs/utils/log.pyi

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,33 @@
11
import logging.config
2-
from logging import LogRecord
3-
from typing import Any, Callable, Dict, List, Optional, Union
2+
from typing import Any, Callable, Dict, Optional
43

54
from django.core.mail.backends.locmem import EmailBackend
5+
from django.core.management.color import Style
66

77
request_logger: Any
88
DEFAULT_LOGGING: Any
99

10-
def configure_logging(
11-
logging_config: str, logging_settings: Dict[str, Union[Dict[str, Dict[str, Union[List[str], bool, str]]], int]]
12-
) -> None: ...
10+
def configure_logging(logging_config: str, logging_settings: Dict[str, Any]) -> None: ...
1311

1412
class AdminEmailHandler(logging.Handler):
15-
filters: List[django.utils.log.RequireDebugFalse]
16-
formatter: None
17-
level: int
18-
lock: _thread.RLock
1913
include_html: bool = ...
2014
email_backend: Optional[str] = ...
21-
def __init__(self, include_html: bool = ..., email_backend: None = ...) -> None: ...
22-
def emit(self, record: LogRecord) -> None: ...
15+
def __init__(self, include_html: bool = ..., email_backend: Optional[str] = ...) -> None: ...
2316
def send_mail(self, subject: str, message: str, *args: Any, **kwargs: Any) -> None: ...
2417
def connection(self) -> EmailBackend: ...
2518
def format_subject(self, subject: str) -> str: ...
2619

2720
class CallbackFilter(logging.Filter):
2821
callback: Callable = ...
2922
def __init__(self, callback: Callable) -> None: ...
30-
def filter(self, record: str) -> int: ...
31-
32-
class RequireDebugFalse(logging.Filter):
33-
name: str
34-
nlen: int
35-
def filter(self, record: Union[LogRecord, str]) -> bool: ...
3623

37-
class RequireDebugTrue(logging.Filter):
38-
name: str
39-
nlen: int
40-
def filter(self, record: Union[LogRecord, str]) -> bool: ...
24+
class RequireDebugFalse(logging.Filter): ...
25+
class RequireDebugTrue(logging.Filter): ...
4126

4227
class ServerFormatter(logging.Formatter):
4328
datefmt: None
44-
style: django.core.management.color.Style = ...
29+
style: Style = ...
4530
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
46-
def format(self, record: LogRecord) -> str: ...
4731
def uses_server_time(self) -> bool: ...
4832

4933
def log_response(

django-stubs/views/debug.pyi

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
from importlib.abc import SourceLoader
12
from typing import Any, Callable, Dict, List, Optional, Type, Union
3+
from types import TracebackType
24

35
from django.core.handlers.wsgi import WSGIRequest
46
from django.http.request import QueryDict
@@ -16,8 +18,8 @@ class CallableSettingWrapper:
1618
def cleanse_setting(key: Union[int, str], value: Any) -> Any: ...
1719
def get_safe_settings() -> Dict[str, Any]: ...
1820
def technical_500_response(request: Any, exc_type: Any, exc_value: Any, tb: Any, status_code: int = ...): ...
19-
def get_default_exception_reporter_filter() -> SafeExceptionReporterFilter: ...
20-
def get_exception_reporter_filter(request: Optional[WSGIRequest]) -> SafeExceptionReporterFilter: ...
21+
def get_default_exception_reporter_filter() -> ExceptionReporterFilter: ...
22+
def get_exception_reporter_filter(request: Optional[WSGIRequest]) -> ExceptionReporterFilter: ...
2123

2224
class ExceptionReporterFilter:
2325
def get_post_parameters(self, request: Any): ...
@@ -32,7 +34,7 @@ class SafeExceptionReporterFilter(ExceptionReporterFilter):
3234

3335
class ExceptionReporter:
3436
request: Optional[WSGIRequest] = ...
35-
filter: django.views.debug.SafeExceptionReporterFilter = ...
37+
filter: ExceptionReporterFilter = ...
3638
exc_type: None = ...
3739
exc_value: Optional[str] = ...
3840
tb: None = ...
@@ -41,12 +43,25 @@ class ExceptionReporter:
4143
template_does_not_exist: bool = ...
4244
postmortem: None = ...
4345
def __init__(
44-
self, request: Optional[WSGIRequest], exc_type: None, exc_value: Optional[str], tb: None, is_email: bool = ...
46+
self,
47+
request: Optional[WSGIRequest],
48+
exc_type: Optional[Type[BaseException]],
49+
exc_value: Optional[Union[str, BaseException]],
50+
tb: Optional[TracebackType],
51+
is_email: bool = ...,
4552
) -> None: ...
4653
def get_traceback_data(self) -> Dict[str, Any]: ...
4754
def get_traceback_html(self) -> SafeText: ...
4855
def get_traceback_text(self) -> SafeText: ...
4956
def get_traceback_frames(self) -> List[Any]: ...
57+
def _get_lines_from_file(
58+
self,
59+
filename: str,
60+
lineno: int,
61+
context_lines: int,
62+
loader: Optional[SourceLoader] = ...,
63+
module_name: Optional[str] = None,
64+
): ...
5065

5166
def technical_404_response(request: WSGIRequest, exception: Http404) -> HttpResponse: ...
5267
def default_urlconf(request: WSGIRequest) -> HttpResponse: ...

django-stubs/views/static.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ DEFAULT_DIRECTORY_INDEX_TEMPLATE: str
99
template_translatable: Any
1010

1111
def directory_index(path: Any, fullpath: Any): ...
12-
def was_modified_since(header: None = ..., mtime: float = ..., size: int = ...) -> bool: ...
12+
def was_modified_since(header: Optional[str] = ..., mtime: float = ..., size: int = ...) -> bool: ...

scripts/typecheck_tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@
125125
],
126126
'select_related_onetoone': [
127127
'"None" has no attribute'
128+
],
129+
'view_tests': [
130+
'"Handler" has no attribute "include_html"',
131+
'"EmailMessage" has no attribute "alternatives"'
128132
]
129133
}
130134
# Test folders to typecheck
@@ -330,7 +334,7 @@
330334
# TODO: 'validation',
331335
'validators',
332336
'version',
333-
# TODO: 'view_tests',
337+
'view_tests',
334338
# TODO: 'wsgi',
335339
]
336340

0 commit comments

Comments
 (0)