mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-21 03:11:17 +08:00
Standardize all context manager __exit__ methods (#1194)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import os
|
from types import TracebackType
|
||||||
import types
|
|
||||||
from typing import IO, AnyStr, Iterator, Optional, Type, TypeVar, Union, type_check_only
|
from typing import IO, AnyStr, Iterator, Optional, Type, TypeVar, Union, type_check_only
|
||||||
|
|
||||||
from django.core.files.utils import FileProxyMixin
|
from django.core.files.utils import FileProxyMixin
|
||||||
@@ -26,7 +25,7 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]):
|
|||||||
self,
|
self,
|
||||||
exc_type: Optional[Type[BaseException]],
|
exc_type: Optional[Type[BaseException]],
|
||||||
exc_value: Optional[BaseException],
|
exc_value: Optional[BaseException],
|
||||||
tb: Optional[types.TracebackType],
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
|
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
|
||||||
def close(self) -> None: ...
|
def close(self) -> None: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import types
|
from types import TracebackType
|
||||||
from typing import Any, Optional, Sequence, Type, TypeVar
|
from typing import Any, Optional, Sequence, Type, TypeVar
|
||||||
|
|
||||||
from django.core.mail.message import EmailMessage
|
from django.core.mail.message import EmailMessage
|
||||||
@@ -12,6 +12,9 @@ class BaseEmailBackend:
|
|||||||
def close(self) -> None: ...
|
def close(self) -> None: ...
|
||||||
def __enter__(self: _T) -> _T: ...
|
def __enter__(self: _T) -> _T: ...
|
||||||
def __exit__(
|
def __exit__(
|
||||||
self, exc_type: Type[BaseException], exc_value: BaseException, traceback: types.TracebackType
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def send_messages(self, email_messages: Sequence[EmailMessage]) -> int: ...
|
def send_messages(self, email_messages: Sequence[EmailMessage]) -> int: ...
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from logging import Logger
|
from logging import Logger
|
||||||
|
from types import TracebackType
|
||||||
from typing import Any, ContextManager, List, Optional, Sequence, Tuple, Type, Union
|
from typing import Any, ContextManager, List, Optional, Sequence, Tuple, Type, Union
|
||||||
|
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
@@ -47,7 +48,12 @@ class BaseDatabaseSchemaEditor(ContextManager[Any]):
|
|||||||
deferred_sql: Any = ...
|
deferred_sql: Any = ...
|
||||||
atomic: Any = ...
|
atomic: Any = ...
|
||||||
def __enter__(self) -> BaseDatabaseSchemaEditor: ...
|
def __enter__(self) -> BaseDatabaseSchemaEditor: ...
|
||||||
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: ...
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None: ...
|
||||||
def execute(self, sql: Union[Statement, str], params: Optional[Sequence[Any]] = ...) -> None: ...
|
def execute(self, sql: Union[Statement, str], params: Optional[Sequence[Any]] = ...) -> None: ...
|
||||||
def quote_name(self, name: str) -> str: ...
|
def quote_name(self, name: str) -> str: ...
|
||||||
def column_sql(
|
def column_sql(
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import types
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from logging import Logger
|
from logging import Logger
|
||||||
|
from types import TracebackType
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Dict,
|
Dict,
|
||||||
@@ -48,9 +48,9 @@ class CursorWrapper:
|
|||||||
def __enter__(self) -> CursorWrapper: ...
|
def __enter__(self) -> CursorWrapper: ...
|
||||||
def __exit__(
|
def __exit__(
|
||||||
self,
|
self,
|
||||||
type: Optional[Type[BaseException]],
|
exc_type: Optional[Type[BaseException]],
|
||||||
value: Optional[BaseException],
|
exc_value: Optional[BaseException],
|
||||||
traceback: Optional[types.TracebackType],
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def callproc(
|
def callproc(
|
||||||
self, procname: str, params: Optional[Sequence[Any]] = ..., kparams: Optional[Dict[str, int]] = ...
|
self, procname: str, params: Optional[Sequence[Any]] = ..., kparams: Optional[Dict[str, int]] = ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from contextlib import ContextDecorator, contextmanager
|
from contextlib import contextmanager
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any, Callable, Iterator, Optional, Type, TypeVar, overload
|
from typing import Any, Callable, Iterator, Optional, Type, TypeVar, overload
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class Atomic:
|
|||||||
self,
|
self,
|
||||||
exc_type: Optional[Type[BaseException]],
|
exc_type: Optional[Type[BaseException]],
|
||||||
exc_value: Optional[BaseException],
|
exc_value: Optional[BaseException],
|
||||||
traceback: Optional[TracebackType],
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
# Bare decorator
|
# Bare decorator
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, Type
|
from typing import Any, Dict, Iterable, List, Optional, Type
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
@@ -24,7 +24,10 @@ class DatabaseErrorWrapper:
|
|||||||
def __init__(self, wrapper: Any) -> None: ...
|
def __init__(self, wrapper: Any) -> None: ...
|
||||||
def __enter__(self) -> None: ...
|
def __enter__(self) -> None: ...
|
||||||
def __exit__(
|
def __exit__(
|
||||||
self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: TracebackType
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
def load_backend(backend_name: str) -> Any: ...
|
def load_backend(backend_name: str) -> Any: ...
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from types import TracebackType
|
||||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, TypeVar, Union
|
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, TypeVar, Union
|
||||||
|
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
@@ -16,7 +17,12 @@ class ContextDict(dict):
|
|||||||
context: BaseContext = ...
|
context: BaseContext = ...
|
||||||
def __init__(self, context: BaseContext, *args: Any, **kwargs: Any) -> None: ...
|
def __init__(self, context: BaseContext, *args: Any, **kwargs: Any) -> None: ...
|
||||||
def __enter__(self) -> ContextDict: ...
|
def __enter__(self) -> ContextDict: ...
|
||||||
def __exit__(self, *args: Any, **kwargs: Any) -> None: ...
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class BaseContext(Iterable[Any]):
|
class BaseContext(Iterable[Any]):
|
||||||
def __init__(self, dict_: Any = ...) -> None: ...
|
def __init__(self, dict_: Any = ...) -> None: ...
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import threading
|
import threading
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
from types import TracebackType
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Callable,
|
Callable,
|
||||||
@@ -50,10 +51,15 @@ class _AssertTemplateUsedContext:
|
|||||||
context: ContextList = ...
|
context: ContextList = ...
|
||||||
def __init__(self, test_case: Any, template_name: Any) -> None: ...
|
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 on_template_render(self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any) -> None: ...
|
||||||
def test(self): ...
|
def test(self) -> None: ...
|
||||||
def message(self): ...
|
def message(self) -> str: ...
|
||||||
def __enter__(self): ...
|
def __enter__(self) -> _AssertTemplateUsedContext: ...
|
||||||
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ...
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext): ...
|
class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext): ...
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from contextlib import contextmanager
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from logging import Logger
|
from logging import Logger
|
||||||
|
from types import TracebackType
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Callable,
|
Callable,
|
||||||
@@ -61,7 +62,12 @@ class TestContextDecorator:
|
|||||||
def enable(self) -> Any: ...
|
def enable(self) -> Any: ...
|
||||||
def disable(self) -> None: ...
|
def disable(self) -> None: ...
|
||||||
def __enter__(self) -> Optional[Apps]: ...
|
def __enter__(self) -> Optional[Apps]: ...
|
||||||
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None: ...
|
||||||
def decorate_class(self, cls: _TestClass) -> _TestClass: ...
|
def decorate_class(self, cls: _TestClass) -> _TestClass: ...
|
||||||
def decorate_callable(self, func: _C) -> _C: ...
|
def decorate_callable(self, func: _C) -> _C: ...
|
||||||
def __call__(self, decorated: _DecoratedTest) -> Any: ...
|
def __call__(self, decorated: _DecoratedTest) -> Any: ...
|
||||||
@@ -100,7 +106,12 @@ class CaptureQueriesContext:
|
|||||||
@property
|
@property
|
||||||
def captured_queries(self) -> List[Dict[str, str]]: ...
|
def captured_queries(self) -> List[Dict[str, str]]: ...
|
||||||
def __enter__(self) -> CaptureQueriesContext: ...
|
def __enter__(self) -> CaptureQueriesContext: ...
|
||||||
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class ignore_warnings(TestContextDecorator):
|
class ignore_warnings(TestContextDecorator):
|
||||||
ignore_kwargs: Dict[str, Any] = ...
|
ignore_kwargs: Dict[str, Any] = ...
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Archive:
|
|||||||
exc_type: Optional[Type[BaseException]],
|
exc_type: Optional[Type[BaseException]],
|
||||||
exc_value: Optional[BaseException],
|
exc_value: Optional[BaseException],
|
||||||
traceback: Optional[TracebackType],
|
traceback: Optional[TracebackType],
|
||||||
) -> Optional[bool]: ...
|
) -> None: ...
|
||||||
def extract(self, to_path: str) -> None: ...
|
def extract(self, to_path: str) -> None: ...
|
||||||
def list(self) -> None: ...
|
def list(self) -> None: ...
|
||||||
def close(self) -> None: ...
|
def close(self) -> None: ...
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import types
|
|
||||||
from contextlib import ContextDecorator
|
from contextlib import ContextDecorator
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from datetime import datetime as datetime
|
from datetime import datetime as datetime
|
||||||
@@ -6,6 +5,7 @@ from datetime import time
|
|||||||
from datetime import timedelta as timedelta
|
from datetime import timedelta as timedelta
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
from datetime import tzinfo as tzinfo
|
from datetime import tzinfo as tzinfo
|
||||||
|
from types import TracebackType
|
||||||
from typing import Any, Optional, Type, Union, overload
|
from typing import Any, Optional, Type, Union, overload
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
@@ -38,7 +38,7 @@ class override(ContextDecorator):
|
|||||||
self,
|
self,
|
||||||
exc_type: Optional[Type[BaseException]],
|
exc_type: Optional[Type[BaseException]],
|
||||||
exc_value: Optional[BaseException],
|
exc_value: Optional[BaseException],
|
||||||
traceback: Optional[types.TracebackType],
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
def localtime(value: Optional[datetime] = ..., timezone: Optional[_TzInfoT] = ...) -> datetime: ...
|
def localtime(value: Optional[datetime] = ..., timezone: Optional[_TzInfoT] = ...) -> datetime: ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import functools
|
import functools
|
||||||
import types
|
|
||||||
from contextlib import ContextDecorator
|
from contextlib import ContextDecorator
|
||||||
|
from types import TracebackType
|
||||||
from typing import Any, Callable, Optional, Type, Union
|
from typing import Any, Callable, Optional, Type, Union
|
||||||
|
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
@@ -60,7 +60,7 @@ class override(ContextDecorator):
|
|||||||
self,
|
self,
|
||||||
exc_type: Optional[Type[BaseException]],
|
exc_type: Optional[Type[BaseException]],
|
||||||
exc_value: Optional[BaseException],
|
exc_value: Optional[BaseException],
|
||||||
traceback: Optional[types.TracebackType],
|
exc_tb: Optional[TracebackType],
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
def get_language() -> str: ...
|
def get_language() -> str: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user