Improve many __(a)exit__ annotations (#9696)

This commit is contained in:
Avasam
2023-02-25 16:50:30 -05:00
committed by GitHub
parent db821101b8
commit 52ec44fa58
45 changed files with 216 additions and 81 deletions

View File

@@ -1,4 +1,5 @@
import abc
from types import TracebackType
class ReversibleProxy: ...
@@ -8,7 +9,9 @@ class StartableContext(abc.ABC, metaclass=abc.ABCMeta):
def __await__(self): ...
async def __aenter__(self): ...
@abc.abstractmethod
async def __aexit__(self, type_, value, traceback): ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
class ProxyComparable(ReversibleProxy):
def __hash__(self) -> int: ...

View File

@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from types import TracebackType
from typing import Any
from .base import ProxyComparable, StartableContext
@@ -39,7 +40,9 @@ class AsyncConnection(ProxyComparable, StartableContext, AsyncConnectable):
async def stream_scalars(self, statement, parameters: Incomplete | None = ..., execution_options=...): ...
async def run_sync(self, fn, *arg, **kw): ...
def __await__(self): ...
async def __aexit__(self, type_, value, traceback) -> None: ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
# proxied from Connection
dialect: Any
@property
@@ -55,7 +58,9 @@ class AsyncEngine(ProxyComparable, AsyncConnectable):
def __init__(self, conn) -> None: ...
transaction: Any
async def start(self, is_ctxmanager: bool = ...): ...
async def __aexit__(self, type_, value, traceback) -> None: ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
sync_engine: Any
def __init__(self, sync_engine) -> None: ...
def begin(self): ...
@@ -91,4 +96,6 @@ class AsyncTransaction(ProxyComparable, StartableContext):
async def rollback(self) -> None: ...
async def commit(self) -> None: ...
async def start(self, is_ctxmanager: bool = ...): ...
async def __aexit__(self, type_, value, traceback) -> None: ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...

View File

@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from types import TracebackType
from typing import Any
from typing_extensions import Self
@@ -55,7 +56,9 @@ class AsyncSession(ReversibleProxy):
@classmethod
async def close_all(cls): ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, type_, value, traceback) -> None: ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
# proxied from Session
identity_map: Any
autoflush: Any
@@ -92,7 +95,9 @@ class _AsyncSessionContextManager:
def __init__(self, async_session) -> None: ...
trans: Any
async def __aenter__(self): ...
async def __aexit__(self, type_, value, traceback) -> None: ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
class AsyncSessionTransaction(ReversibleProxy, StartableContext):
session: Any
@@ -104,7 +109,9 @@ class AsyncSessionTransaction(ReversibleProxy, StartableContext):
async def rollback(self) -> None: ...
async def commit(self) -> None: ...
async def start(self, is_ctxmanager: bool = ...): ...
async def __aexit__(self, type_, value, traceback) -> None: ...
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def async_object_session(instance): ...
def async_session(session): ...

View File

@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Mapping
from types import TracebackType
from typing import Any, TypeVar, overload
from typing_extensions import Self
@@ -107,7 +108,9 @@ class Session(_SessionClassMethods):
) -> None: ...
connection_callable: Any
def __enter__(self) -> Self: ...
def __exit__(self, type_, value, traceback) -> None: ...
def __exit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
@property
def transaction(self): ...
def in_transaction(self): ...

View File

@@ -1,3 +1,4 @@
from types import TracebackType
from typing import Any
class _AsyncGeneratorContextManager:
@@ -5,6 +6,8 @@ class _AsyncGeneratorContextManager:
__doc__: Any
def __init__(self, func, args, kwds) -> None: ...
async def __aenter__(self): ...
async def __aexit__(self, typ, value, traceback): ...
async def __aexit__(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
def asynccontextmanager(func): ...

View File

@@ -1,4 +1,5 @@
import asyncio as asyncio
from _typeshed import Unused
from collections.abc import Callable, Coroutine
from typing import Any
@@ -13,6 +14,6 @@ class AsyncAdaptedLock:
@memoized_property
def mutex(self): ...
def __enter__(self): ...
def __exit__(self, *arg, **kw) -> None: ...
def __exit__(self, *arg: Unused, **kw: Unused) -> None: ...
def get_event_loop(): ...

View File

@@ -5,7 +5,7 @@ import itertools
import operator
import pickle as pickle
import threading as threading
from _typeshed import Incomplete
from _typeshed import Incomplete, Unused
from abc import ABC as ABC
from datetime import timezone as timezone
from functools import reduce as reduce
@@ -53,7 +53,7 @@ class nullcontext:
enter_result: Any
def __init__(self, enter_result: Incomplete | None = ...) -> None: ...
def __enter__(self): ...
def __exit__(self, *excinfo) -> None: ...
def __exit__(self, *excinfo: Unused) -> None: ...
def inspect_getfullargspec(func): ...
def importlib_metadata_get(group): ...

View File

@@ -1,5 +1,6 @@
from _typeshed import Incomplete, Unused
from collections.abc import Callable
from types import TracebackType
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self
@@ -13,7 +14,9 @@ class safe_reraise:
warn_only: Any
def __init__(self, warn_only: bool = ...) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, type_, value, traceback) -> None: ...
def __exit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def walk_subclasses(cls) -> None: ...
def string_or_unprintable(element): ...