Skip to content

Update __exit__ parameters in stubs #9696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stubs/JACK-Client/jack/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _typeshed import Unused
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from typing import Any, NoReturn, overload
from typing_extensions import Literal, Self
Expand Down Expand Up @@ -80,7 +81,7 @@ class Client:
session_id: str | None = ...,
) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
@property
def name(self) -> str: ...
@property
Expand Down
4 changes: 2 additions & 2 deletions stubs/Pillow/PIL/Image.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete, SupportsRead, SupportsWrite
from _typeshed import Incomplete, SupportsRead, SupportsWrite, Unused
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
from enum import IntEnum
from pathlib import Path
Expand Down Expand Up @@ -172,7 +172,7 @@ class Image:
@property
def size(self) -> tuple[int, int]: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
def close(self) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> _ImageState: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/Pillow/PIL/ImageFile.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, Unused
from typing import Any, NoReturn
from typing_extensions import Self

Expand Down Expand Up @@ -42,7 +42,7 @@ class Parser:
decode: Any
def feed(self, data) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
def close(self) -> Image: ...

class PyCodecState:
Expand Down
6 changes: 5 additions & 1 deletion stubs/Pillow/PIL/PdfParser.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import collections
from _typeshed import Incomplete
from types import TracebackType
from typing import Any
from typing_extensions import Literal

def encode_text(s: str) -> bytes: ...

Expand Down Expand Up @@ -95,7 +97,9 @@ class PdfParser:
mode: str = ...,
) -> None: ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_value, traceback): ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> Literal[False]: ...
def start_writing(self) -> None: ...
def close_buf(self) -> None: ...
def close(self) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/Pillow/PIL/PngImagePlugin.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, Unused
from enum import IntEnum
from typing import Any, ClassVar
from typing_extensions import Literal
Expand Down Expand Up @@ -33,7 +33,7 @@ class ChunkStream:
def __init__(self, fp) -> None: ...
def read(self): ...
def __enter__(self): ...
def __exit__(self, *args) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
def close(self) -> None: ...
def push(self, cid, pos, length) -> None: ...
def call(self, cid, pos, length): ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/Pillow/PIL/TarIO.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import Unused
from typing import Any

from .ContainerIO import ContainerIO
Expand All @@ -6,5 +7,5 @@ class TarIO(ContainerIO):
fh: Any
def __init__(self, tarfile, file) -> None: ...
def __enter__(self): ...
def __exit__(self, *args) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
def close(self) -> None: ...
5 changes: 4 additions & 1 deletion stubs/Pillow/PIL/TiffImagePlugin.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
from collections.abc import MutableMapping
from numbers import Rational
from types import TracebackType
from typing import Any, ClassVar
from typing_extensions import Literal

Expand Down Expand Up @@ -171,7 +172,9 @@ class AppendingTiffWriter:
def finalize(self) -> None: ...
def newFrame(self) -> None: ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_value, traceback): ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> Literal[False]: ...
def tell(self): ...
def seek(self, offset, whence=...): ...
def goToEnd(self) -> None: ...
Expand Down
5 changes: 4 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/ext/asyncio/base.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import abc
from types import TracebackType

class ReversibleProxy: ...

Expand All @@ -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: ...
Expand Down
13 changes: 10 additions & 3 deletions stubs/SQLAlchemy/sqlalchemy/ext/asyncio/engine.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from types import TracebackType
from typing import Any

from .base import ProxyComparable, StartableContext
Expand Down Expand Up @@ -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
Expand All @@ -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): ...
Expand Down Expand Up @@ -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: ...
13 changes: 10 additions & 3 deletions stubs/SQLAlchemy/sqlalchemy/ext/asyncio/session.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from types import TracebackType
from typing import Any
from typing_extensions import Self

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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): ...
5 changes: 4 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/orm/session.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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): ...
Expand Down
5 changes: 4 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/util/_compat_py3k.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from types import TracebackType
from typing import Any

class _AsyncGeneratorContextManager:
gen: Any
__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): ...
3 changes: 2 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/util/_concurrency_py3k.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio as asyncio
from _typeshed import Unused
from collections.abc import Callable, Coroutine
from typing import Any

Expand All @@ -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(): ...
4 changes: 2 additions & 2 deletions stubs/SQLAlchemy/sqlalchemy/util/compat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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): ...
Expand Down
5 changes: 4 additions & 1 deletion stubs/SQLAlchemy/sqlalchemy/util/langhelpers.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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): ...
Expand Down
9 changes: 7 additions & 2 deletions stubs/aws-xray-sdk/aws_xray_sdk/core/async_recorder.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from types import TracebackType

from .models.segment import SegmentContextManager as SegmentContextManager
from .models.subsegment import (
Expand All @@ -11,12 +12,16 @@ from .utils import stacktrace as stacktrace

class AsyncSegmentContextManager(SegmentContextManager):
async def __aenter__(self): ...
async def __aexit__(self, exc_type, exc_val, exc_tb): ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

class AsyncSubsegmentContextManager(SubsegmentContextManager):
async def __call__(self, wrapped, instance, args, kwargs): ...
async def __aenter__(self): ...
async def __aexit__(self, exc_type, exc_val, exc_tb): ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

class AsyncAWSXRayRecorder(AWSXRayRecorder):
def capture_async(self, name: Incomplete | None = ...): ...
Expand Down
5 changes: 4 additions & 1 deletion stubs/aws-xray-sdk/aws_xray_sdk/core/models/segment.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from types import TracebackType
from typing import Any

from ..exceptions.exceptions import SegmentNameMissingException as SegmentNameMissingException
Expand All @@ -16,7 +17,9 @@ class SegmentContextManager:
segment: Segment
def __init__(self, recorder: AWSXRayRecorder, name: str | None = ..., **segment_kwargs) -> None: ...
def __enter__(self): ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

class Segment(Entity):
trace_id: str | None
Expand Down
5 changes: 4 additions & 1 deletion stubs/aws-xray-sdk/aws_xray_sdk/core/models/subsegment.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
from _typeshed import Incomplete
from types import TracebackType
from typing import Any

from ...core import AWSXRayRecorder
Expand All @@ -21,7 +22,9 @@ class SubsegmentContextManager:
def __init__(self, recorder: AWSXRayRecorder, name: Incomplete | None = ..., **subsegment_kwargs) -> None: ...
def __call__(self, wrapped, instance, args: list[Any], kwargs: dict[str, Any]): ...
def __enter__(self) -> Subsegment: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

class Subsegment(Entity):
parent_segment: Segment
Expand Down
4 changes: 2 additions & 2 deletions stubs/cachetools/cachetools/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import IdentityFunction
from _typeshed import IdentityFunction, Unused
from collections.abc import Callable, Iterator, MutableMapping, Sequence
from contextlib import AbstractContextManager
from typing import Any, Generic, TypeVar, overload
Expand Down Expand Up @@ -66,7 +66,7 @@ class _TimedCache(Cache[_KT, _VT]):
def __init__(self, timer: Callable[[], float]) -> None: ...
def __call__(self) -> float: ...
def __enter__(self) -> float: ...
def __exit__(self, *exc: object) -> None: ...
def __exit__(self, *exc: Unused) -> None: ...

@property
def timer(self) -> _Timer: ...
Expand Down
5 changes: 4 additions & 1 deletion stubs/caldav/caldav/davclient.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Iterable, Mapping
from types import TracebackType
from typing import Any
from typing_extensions import Self, TypeAlias
from urllib.parse import ParseResult, SplitResult
Expand Down Expand Up @@ -50,7 +51,9 @@ class DAVClient:
ssl_cert: str | tuple[str, str] | None = ...,
) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
Copy link
Collaborator Author

@Avasam Avasam Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be typed with objects. Please validate it's still correct.

) -> None: ...
def principal(self, *, url: str | ParseResult | SplitResult | URL | None = ...) -> Principal: ...
def calendar(
self,
Expand Down
2 changes: 1 addition & 1 deletion stubs/cffi/_cffi_backend.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _CDataBase:
def __dir__(self): ...
def __enter__(self): ...
def __eq__(self, other): ...
def __exit__(self, type, value, traceback): ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None): ...
def __float__(self) -> float: ...
def __ge__(self, other): ...
def __getitem__(self, index): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/humanfriendly/humanfriendly/testing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MockedProgram(CustomSearchPath):
program_signal_file: Any
def __init__(self, name, returncode: int = ..., script: Incomplete | None = ...) -> None: ...
def __enter__(self): ...
def __exit__(self, *args, **kw): ...
def __exit__(self, *args: object, **kw: object): ...

class CaptureOutput(ContextManager):
stdin: Any
Expand Down
Loading