Skip to content

Commit

Permalink
remove redundant overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfischer2781 committed Mar 9, 2024
1 parent a1d5a3c commit b5fa504
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
18 changes: 2 additions & 16 deletions asyncstdlib/contextlib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations
from typing import (
TypeVar,
Generic,
Expand All @@ -9,7 +8,6 @@
Any,
Awaitable,
Deque,
overload,
AsyncContextManager,
)
from functools import wraps
Expand Down Expand Up @@ -184,22 +182,10 @@ async def safe_fetch(source):

__slots__ = ("enter_result",)

@overload
def __init__(self: NullContext[None], enter_result: None = ...) -> None: ...

@overload
def __init__(self: NullContext[T], enter_result: T) -> None: ...

def __init__(self, enter_result: Optional[T] = None):
def __init__(self, enter_result: T = None):
self.enter_result = enter_result

@overload
async def __aenter__(self: NullContext[None]) -> None: ...

@overload
async def __aenter__(self: NullContext[T]) -> T: ...

async def __aenter__(self) -> Optional[T]:
async def __aenter__(self) -> T:
return self.enter_result

async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
Expand Down
3 changes: 0 additions & 3 deletions asyncstdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class nullcontext(AsyncContextManager[T]):
def __init__(self: nullcontext[None], enter_result: None = ...) -> None: ...
@overload
def __init__(self: nullcontext[T], enter_result: T) -> None: ...
@overload
async def __aenter__(self: nullcontext[None]) -> None: ...
@overload
async def __aenter__(self: nullcontext[T]) -> T: ...
async def __aexit__(
self,
Expand Down

0 comments on commit b5fa504

Please sign in to comment.