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
|
||||
import types
|
||||
from types import TracebackType
|
||||
from typing import IO, AnyStr, Iterator, Optional, Type, TypeVar, Union, type_check_only
|
||||
|
||||
from django.core.files.utils import FileProxyMixin
|
||||
@@ -26,7 +25,7 @@ class File(FileProxyMixin[AnyStr], IO[AnyStr]):
|
||||
self,
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
tb: Optional[types.TracebackType],
|
||||
exc_tb: Optional[TracebackType],
|
||||
) -> None: ...
|
||||
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import types
|
||||
from types import TracebackType
|
||||
from typing import Any, Optional, Sequence, Type, TypeVar
|
||||
|
||||
from django.core.mail.message import EmailMessage
|
||||
@@ -12,6 +12,9 @@ class BaseEmailBackend:
|
||||
def close(self) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
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: ...
|
||||
def send_messages(self, email_messages: Sequence[EmailMessage]) -> int: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import Any, ContextManager, List, Optional, Sequence, Tuple, Type, Union
|
||||
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
@@ -47,7 +48,12 @@ class BaseDatabaseSchemaEditor(ContextManager[Any]):
|
||||
deferred_sql: Any = ...
|
||||
atomic: Any = ...
|
||||
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 quote_name(self, name: str) -> str: ...
|
||||
def column_sql(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import datetime
|
||||
import types
|
||||
from contextlib import contextmanager
|
||||
from decimal import Decimal
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
@@ -48,9 +48,9 @@ class CursorWrapper:
|
||||
def __enter__(self) -> CursorWrapper: ...
|
||||
def __exit__(
|
||||
self,
|
||||
type: Optional[Type[BaseException]],
|
||||
value: Optional[BaseException],
|
||||
traceback: Optional[types.TracebackType],
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
exc_tb: Optional[TracebackType],
|
||||
) -> None: ...
|
||||
def callproc(
|
||||
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 typing import Any, Callable, Iterator, Optional, Type, TypeVar, overload
|
||||
|
||||
@@ -35,7 +35,7 @@ class Atomic:
|
||||
self,
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
traceback: Optional[TracebackType],
|
||||
exc_tb: Optional[TracebackType],
|
||||
) -> None: ...
|
||||
|
||||
# Bare decorator
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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.db.backends.base.base import BaseDatabaseWrapper
|
||||
@@ -24,7 +24,10 @@ class DatabaseErrorWrapper:
|
||||
def __init__(self, wrapper: Any) -> None: ...
|
||||
def __enter__(self) -> None: ...
|
||||
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: ...
|
||||
|
||||
def load_backend(backend_name: str) -> Any: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from contextlib import contextmanager
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, TypeVar, Union
|
||||
|
||||
from django.http.request import HttpRequest
|
||||
@@ -16,7 +17,12 @@ class ContextDict(dict):
|
||||
context: BaseContext = ...
|
||||
def __init__(self, context: BaseContext, *args: Any, **kwargs: Any) -> None: ...
|
||||
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]):
|
||||
def __init__(self, dict_: Any = ...) -> None: ...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import threading
|
||||
import unittest
|
||||
from datetime import date
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
@@ -50,10 +51,15 @@ class _AssertTemplateUsedContext:
|
||||
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): ...
|
||||
def message(self): ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ...
|
||||
def test(self) -> None: ...
|
||||
def message(self) -> str: ...
|
||||
def __enter__(self) -> _AssertTemplateUsedContext: ...
|
||||
def __exit__(
|
||||
self,
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
exc_tb: Optional[TracebackType],
|
||||
) -> None: ...
|
||||
|
||||
class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext): ...
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from contextlib import contextmanager
|
||||
from decimal import Decimal
|
||||
from io import StringIO
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
@@ -61,7 +62,12 @@ class TestContextDecorator:
|
||||
def enable(self) -> Any: ...
|
||||
def disable(self) -> None: ...
|
||||
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_callable(self, func: _C) -> _C: ...
|
||||
def __call__(self, decorated: _DecoratedTest) -> Any: ...
|
||||
@@ -100,7 +106,12 @@ class CaptureQueriesContext:
|
||||
@property
|
||||
def captured_queries(self) -> List[Dict[str, str]]: ...
|
||||
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):
|
||||
ignore_kwargs: Dict[str, Any] = ...
|
||||
|
||||
@@ -14,7 +14,7 @@ class Archive:
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
traceback: Optional[TracebackType],
|
||||
) -> Optional[bool]: ...
|
||||
) -> None: ...
|
||||
def extract(self, to_path: str) -> None: ...
|
||||
def list(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import types
|
||||
from contextlib import ContextDecorator
|
||||
from datetime import date
|
||||
from datetime import datetime as datetime
|
||||
@@ -6,6 +5,7 @@ from datetime import time
|
||||
from datetime import timedelta as timedelta
|
||||
from datetime import timezone
|
||||
from datetime import tzinfo as tzinfo
|
||||
from types import TracebackType
|
||||
from typing import Any, Optional, Type, Union, overload
|
||||
|
||||
import pytz
|
||||
@@ -38,7 +38,7 @@ class override(ContextDecorator):
|
||||
self,
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
traceback: Optional[types.TracebackType],
|
||||
exc_tb: Optional[TracebackType],
|
||||
) -> None: ...
|
||||
|
||||
def localtime(value: Optional[datetime] = ..., timezone: Optional[_TzInfoT] = ...) -> datetime: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import functools
|
||||
import types
|
||||
from contextlib import ContextDecorator
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Optional, Type, Union
|
||||
|
||||
from django.http.request import HttpRequest
|
||||
@@ -60,7 +60,7 @@ class override(ContextDecorator):
|
||||
self,
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
traceback: Optional[types.TracebackType],
|
||||
exc_tb: Optional[TracebackType],
|
||||
) -> None: ...
|
||||
|
||||
def get_language() -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user