more cleanups

This commit is contained in:
Maxim Kurnikov
2018-12-22 04:42:37 +03:00
parent 59b8008a21
commit 9a2b88b270
117 changed files with 94 additions and 2798 deletions

View File

@@ -1,7 +1,6 @@
import collections
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable
from django.apps.config import AppConfig
from django.db.migrations.state import AppConfigStub
from django.db.models.base import Model

View File

@@ -10,3 +10,6 @@ class LazySettings(_DjangoConfLazyObject):
def configure(self, default_settings: Any = ..., **options: Any) -> Any: ...
settings: LazySettings = ...
class Settings: ...
class UserSettingsHolder: ...

View File

@@ -4,7 +4,7 @@ from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
class StaticFilesHandler(WSGIHandler):
handles_files: bool = ...
application: django.core.handlers.wsgi.WSGIHandler = ...
application: WSGIHandler = ...
base_url: Any = ...
def __init__(self, application: WSGIHandler) -> None: ...
def load_middleware(self) -> None: ...

View File

@@ -5,7 +5,7 @@ from django.db.backends.base.base import BaseDatabaseWrapper
TEST_DATABASE_PREFIX: str
class BaseDatabaseCreation:
connection: django.db.backends.sqlite3.base.DatabaseWrapper = ...
connection: Any = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def create_test_db(
self, verbosity: int = ..., autoclobber: bool = ..., serialize: bool = ..., keepdb: bool = ...

View File

@@ -24,7 +24,7 @@ class BaseDatabaseOperations:
UNBOUNDED_FOLLOWING: Any = ...
CURRENT_ROW: str = ...
explain_prefix: Any = ...
connection: django.db.DefaultConnectionProxy = ...
connection: Any = ...
def __init__(self, connection: Union[DefaultConnectionProxy, BaseDatabaseWrapper]) -> None: ...
def autoinc_sql(self, table: str, column: str) -> None: ...
def bulk_batch_size(self, fields: Any, objs: Any): ...

View File

@@ -4,7 +4,7 @@ from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models.fields import Field
class BaseDatabaseValidation:
connection: django.db.backends.sqlite3.base.DatabaseWrapper = ...
connection: Any = ...
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def check_field(self, field: Field, **kwargs: Any) -> List[Any]: ...

View File

@@ -32,6 +32,6 @@ class MigrationLoader:
graph: Any = ...
replacements: Any = ...
def build_graph(self) -> None: ...
def check_consistent_history(self, connection: Union[DefaultConnectionProxy, DatabaseWrapper]) -> None: ...
def check_consistent_history(self, connection: Any) -> None: ...
def detect_conflicts(self) -> Dict[str, Set[str]]: ...
def project_state(self, nodes: Optional[Tuple[str, str]] = ..., at_end: bool = ...) -> ProjectState: ...

View File

@@ -19,7 +19,7 @@ class DjangoTemplates(BaseEngine):
def get_templatetag_libraries(self, custom_libraries: Dict[str, str]) -> Dict[str, str]: ...
class Template:
template: django.template.base.Template = ...
template: Template = ...
backend: django.template.backends.django.DjangoTemplates = ...
def __init__(self, template: Template, backend: DjangoTemplates) -> None: ...
@property

View File

@@ -56,7 +56,7 @@ class Context(BaseContext):
use_tz: Optional[bool] = ...
template_name: Optional[str] = ...
render_context: django.template.context.RenderContext = ...
template: Optional[django.template.base.Template] = ...
template: Optional[Template] = ...
def __init__(
self, dict_: Any = ..., autoescape: bool = ..., use_l10n: Optional[bool] = ..., use_tz: None = ...
) -> None: ...
@@ -66,7 +66,7 @@ class Context(BaseContext):
class RenderContext(BaseContext):
dicts: List[Dict[Union[django.template.loader_tags.IncludeNode, str], str]]
template: Optional[django.template.base.Template] = ...
template: Optional[Template] = ...
def __iter__(self) -> None: ...
def __contains__(self, key: Union[CycleNode, str]) -> bool: ...
def get(self, key: Union[InclusionNode, str], otherwise: None = ...) -> Optional[Union[Template, BlockContext]]: ...
@@ -90,7 +90,7 @@ class RequestContext(Context):
use_tz: None = ...,
autoescape: bool = ...,
) -> None: ...
template: Optional[django.template.base.Template] = ...
template: Optional[Template] = ...
def bind_template(self, template: Template) -> Iterator[None]: ...
def new(
self,

View File

@@ -74,7 +74,7 @@ class InclusionNode(TagHelperNode):
origin: django.template.base.Origin
takes_context: Optional[bool]
token: django.template.base.Token
filename: Union[django.template.base.Template, str] = ...
filename: Union[Template, str] = ...
def __init__(
self,
func: Callable,

View File

@@ -59,7 +59,7 @@ class TemplateResponse(SimpleTemplateResponse):
resolver_match: django.utils.functional.SimpleLazyObject
status_code: int
template_name: Union[List[str], django.template.backends.django.Template, str]
templates: List[django.template.base.Template]
templates: List[Template]
using: Optional[str]
wsgi_request: django.core.handlers.wsgi.WSGIRequest
rendering_attrs: Any = ...

View File

@@ -2,6 +2,7 @@ from .testcases import (
TestCase as TestCase,
TransactionTestCase as TransactionTestCase,
SimpleTestCase as SimpleTestCase,
LiveServerTestCase as LiveServerTestCase,
)
from .utils import override_settings as override_settings

View File

@@ -1,21 +1,18 @@
from datetime import date
from typing import Any, Callable, Dict, List, Optional, Union
from io import BytesIO
from typing import Any, Dict, List, Optional, Union, Tuple, Type
from django.contrib.auth.models import User
from django.contrib.sessions.backends.base import SessionBase
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import WSGIRequest
from django.dispatch.dispatcher import Signal
from django.http.request import HttpRequest, QueryDict
from django.http.response import HttpResponse, HttpResponseBase, HttpResponseRedirect
from django.template.base import Template
from django.template.context import Context
from django.test.utils import ContextList
from django.core.serializers.json import DjangoJSONEncoder
from django.http.cookie import SimpleCookie
from django.http.response import HttpResponse, HttpResponseBase
class RedirectCycleError(Exception):
last_response: django.http.response.HttpResponseRedirect = ...
last_response: HttpResponseBase = ...
redirect_chain: List[Tuple[str, int]] = ...
def __init__(self, message: str, last_response: HttpResponseRedirect) -> None: ...
def __init__(self, message: str, last_response: HttpResponseBase) -> None: ...
class FakePayload:
read_started: bool = ...
@@ -33,22 +30,18 @@ def encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ...
def encode_file(boundary: str, key: str, file: Any) -> List[bytes]: ...
class RequestFactory:
json_encoder: Type[django.core.serializers.json.DjangoJSONEncoder] = ...
json_encoder: Type[DjangoJSONEncoder] = ...
defaults: Dict[str, str] = ...
cookies: http.cookies.SimpleCookie = ...
errors: _io.BytesIO = ...
cookies: SimpleCookie = ...
errors: BytesIO = ...
def __init__(self, *, json_encoder: Any = ..., **defaults: Any) -> None: ...
def request(self, **request: Any) -> WSGIRequest: ...
def get(
self, path: str, data: Optional[Union[Dict[str, date], QueryDict, str]] = ..., secure: bool = ..., **extra: Any
) -> Union[WSGIRequest, HttpResponseBase]: ...
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponseBase: ...
def post(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> Union[WSGIRequest, HttpResponseBase]: ...
def head(
self, path: str, data: Optional[Union[Dict[str, str], str]] = ..., secure: bool = ..., **extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> Union[WSGIRequest, HttpResponse]: ...
) -> HttpResponseBase: ...
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponseBase: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> HttpResponseBase: ...
def options(
self,
path: str,
@@ -56,46 +49,31 @@ class RequestFactory:
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
) -> HttpResponseBase: ...
def put(
self,
path: str,
data: Union[Dict[str, int], Dict[str, str], bytes, str] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponseBase: ...
def patch(
self,
path: str,
data: Union[Dict[str, int], Dict[str, str], str] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponseBase: ...
def delete(
self,
path: str,
data: Union[Dict[str, int], Dict[str, str], str] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponse]: ...
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponseBase: ...
def generic(
self,
method: str,
path: str,
data: Union[Dict[str, str], bytes, str] = ...,
data: Any = ...,
content_type: Optional[str] = ...,
secure: bool = ...,
**extra: Any
) -> Union[WSGIRequest, HttpResponseBase]: ...
) -> HttpResponseBase: ...
class Client(RequestFactory):
defaults: Dict[str, str]
errors: _io.BytesIO
json_encoder: Union[Type[django.core.serializers.json.DjangoJSONEncoder], unittest.mock.MagicMock]
handler: django.test.client.ClientHandler = ...
errors: BytesIO
json_encoder: Type[DjangoJSONEncoder]
handler: ClientHandler = ...
exc_info: None = ...
def __init__(self, enforce_csrf_checks: bool = ..., **defaults: Any) -> None: ...
def store_exc_info(self, **kwargs: Any) -> None: ...
@@ -103,64 +81,30 @@ class Client(RequestFactory):
def session(self) -> SessionBase: ...
def request(self, **request: Any) -> Any: ...
def get(
self,
path: str,
data: Optional[Union[Dict[str, Union[int, str]], QueryDict, str]] = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponseBase: ...
def post(
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponseBase: ...
def head(
self,
path: str,
data: Optional[Union[Dict[str, str], str]] = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def options(
self,
path: str,
data: Union[Dict[str, str], str] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def put(
self,
path: str,
data: Union[Dict[str, int], Dict[str, str], bytes, str] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def patch(
self,
path: str,
data: Union[Dict[str, int], Dict[str, str], str] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def delete(
self,
path: str,
data: Union[Dict[str, int], Dict[str, str], str] = ...,
content_type: str = ...,
follow: bool = ...,
secure: bool = ...,
**extra: Any
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def trace(
self, path: str, data: Union[Dict[str, str], str] = ..., follow: bool = ..., secure: bool = ..., **extra: Any
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def login(self, **credentials: Any) -> bool: ...
def force_login(self, user: User, backend: Optional[str] = ...) -> None: ...
cookies: http.cookies.SimpleCookie = ...
cookies: SimpleCookie = ...
def logout(self) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Tuple, Type, Union
from django.test import LiveServerTestCase

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any
template_rendered: Any
COMPLEX_OVERRIDE_SETTINGS: Any

View File

@@ -5,34 +5,34 @@ from datetime import date
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
from unittest.runner import TextTestResult
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import WSGIHandler
from django.core.servers.basehttp import WSGIRequestHandler
from django.core.servers.basehttp import WSGIRequestHandler, ThreadedWSGIServer
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.query import QuerySet, RawQuerySet
from django.forms.fields import EmailField
from django.http.response import HttpResponse, HttpResponseBase
from django.template.context import Context
from django.test.html import Element
from django.test.utils import CaptureQueriesContext, ContextList, modify_settings, override_settings
from django.template.base import Template
from django.test.utils import CaptureQueriesContext, modify_settings, override_settings, ContextList
from django.utils.safestring import SafeText
class _AssertNumQueriesContext(CaptureQueriesContext):
connection: django.db.backends.sqlite3.base.DatabaseWrapper
connection: Any
final_queries: Optional[int]
force_debug_cursor: bool
initial_queries: int
test_case: Union[django.test.testcases.SerializeMixin, django.test.testcases.TransactionTestCase] = ...
test_case: SimpleTestCase = ...
num: int = ...
def __init__(self, test_case: Any, num: Any, connection: Any) -> None: ...
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ...
class _AssertTemplateUsedContext:
test_case: django.test.testcases.SimpleTestCase = ...
test_case: SimpleTestCase = ...
template_name: str = ...
rendered_templates: List[django.template.base.Template] = ...
rendered_templates: List[Template] = ...
rendered_template_names: List[str] = ...
context: django.test.utils.ContextList = ...
context: ContextList = ...
def __init__(self, test_case: Any, template_name: Any) -> None: ...
def on_template_render(self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any) -> None: ...
def test(self): ...
@@ -41,11 +41,11 @@ class _AssertTemplateUsedContext:
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ...
class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext):
context: django.test.utils.ContextList
context: ContextList
rendered_template_names: List[str]
rendered_templates: List[django.template.base.Template]
rendered_templates: List[Template]
template_name: str
test_case: django.test.testcases.SimpleTestCase
test_case: SimpleTestCase
def test(self): ...
def message(self): ...
@@ -203,9 +203,9 @@ class LiveServerThread(threading.Thread):
host: str = ...
port: int = ...
is_ready: threading.Event = ...
error: Optional[django.core.exceptions.ImproperlyConfigured] = ...
static_handler: Type[django.core.handlers.wsgi.WSGIHandler] = ...
connections_override: Dict[str, django.db.backends.sqlite3.base.DatabaseWrapper] = ...
error: Optional[ImproperlyConfigured] = ...
static_handler: Type[WSGIHandler] = ...
connections_override: Dict[str, Any] = ...
def __init__(
self,
host: str,
@@ -213,7 +213,7 @@ class LiveServerThread(threading.Thread):
connections_override: Dict[str, DatabaseWrapper] = ...,
port: int = ...,
) -> None: ...
httpd: django.core.servers.basehttp.ThreadedWSGIServer = ...
httpd: ThreadedWSGIServer = ...
def run(self) -> None: ...
def terminate(self) -> None: ...

View File

@@ -1,19 +1,14 @@
from collections import OrderedDict
from contextlib import _GeneratorContextManager
import decimal
import warnings
from decimal import Decimal
from io import StringIO
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
from django.apps.registry import Apps
from django.conf import LazySettings
from django.db import DefaultConnectionProxy
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.template.base import Template
from django.template.context import Context
from django.core.checks.registry import CheckRegistry
from django.test.runner import DiscoverRunner
from django.test.testcases import SimpleTestCase
from django.utils.safestring import SafeText
from django.conf import LazySettings
class Approximate:
val: Union[decimal.Decimal, float] = ...
@@ -52,7 +47,7 @@ class override_settings(TestContextDecorator):
kwarg_name: None
options: Dict[str, Any] = ...
def __init__(self, **kwargs: Any) -> None: ...
wrapped: Union[django.conf.Settings, django.conf.UserSettingsHolder] = ...
wrapped: Settings = ...
def enable(self) -> None: ...
def disable(self) -> None: ...
def save_options(self, test_func: Type[Union[SimpleTestCase, LoggingCaptureMixin]]) -> None: ...
@@ -63,7 +58,7 @@ class override_settings(TestContextDecorator):
class modify_settings(override_settings):
attr_name: None
kwarg_name: None
wrapped: Union[django.conf.Settings, django.conf.UserSettingsHolder]
wrapped: Settings
operations: List[Tuple[str, Dict[str, Union[List[str], str]]]] = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def save_options(self, test_func: Type[SimpleTestCase]) -> None: ...
@@ -73,7 +68,7 @@ class modify_settings(override_settings):
class override_system_checks(TestContextDecorator):
attr_name: None
kwarg_name: None
registry: django.core.checks.registry.CheckRegistry = ...
registry: CheckRegistry = ...
new_checks: List[Callable] = ...
deployment_checks: Optional[List[Callable]] = ...
def __init__(self, new_checks: List[Callable], deployment_checks: Optional[List[Callable]] = ...) -> None: ...
@@ -83,8 +78,8 @@ class override_system_checks(TestContextDecorator):
def disable(self) -> None: ...
class CaptureQueriesContext:
connection: django.db.DefaultConnectionProxy = ...
def __init__(self, connection: Union[DefaultConnectionProxy, DatabaseWrapper]) -> None: ...
connection: Any = ...
def __init__(self, connection: Any) -> None: ...
def __iter__(self): ...
def __getitem__(self, index: int) -> Dict[str, str]: ...
def __len__(self) -> int: ...
@@ -99,7 +94,7 @@ class CaptureQueriesContext:
class ignore_warnings(TestContextDecorator):
attr_name: None
kwarg_name: None
ignore_kwargs: Dict[str, Union[Type[django.utils.deprecation.RemovedInDjango30Warning], str]] = ...
ignore_kwargs: Dict[str, Any] = ...
filter_func: Callable = ...
def __init__(self, **kwargs: Any) -> None: ...
catch_warnings: warnings.catch_warnings = ...
@@ -131,6 +126,6 @@ class isolate_apps(TestContextDecorator):
kwarg_name: Optional[str]
installed_apps: Tuple[str] = ...
def __init__(self, *installed_apps: Any, **kwargs: Any) -> None: ...
old_apps: django.apps.registry.Apps = ...
old_apps: Apps = ...
def enable(self) -> Apps: ...
def disable(self) -> None: ...