Skip to content

Commit

Permalink
Replace public usages of functools.wraps
Browse files Browse the repository at this point in the history
  • Loading branch information
A5rocks authored Sep 9, 2023
1 parent be39867 commit 4e62939
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions trio/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def open(
) -> _AsyncIOWrapper[IO[Any]]:
...

# TODO: check the following is AOK with pyright
@wraps(pathlib.Path.open) # type: ignore[misc] # Overload return mismatch.
async def open(self, *args: Any, **kwargs: Any) -> _AsyncIOWrapper[IO[Any]]:
"""Open the file pointed to by the path, like the :func:`trio.open_file`
Expand Down
11 changes: 9 additions & 2 deletions trio/_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import select
import socket as _stdlib_socket
import sys
from functools import wraps as _wraps
from operator import index
from socket import AddressFamily, SocketKind
from typing import (
Expand Down Expand Up @@ -37,9 +36,17 @@

P = ParamSpec("P")


T = TypeVar("T")

# work around a pyright error
if TYPE_CHECKING:
Fn = TypeVar("Fn", bound=Callable[..., object])
def _wraps(f: Fn) -> Fn:
...

Check notice on line 45 in trio/_socket.py

View workflow job for this annotation

GitHub Actions / Ubuntu (3.8, check formatting)

Mypy-Linux+Mac+Windows

trio/_socket.py:(44:5 - 45:11): "_wraps" defined here

else:
from functools import wraps as _wraps

# must use old-style typing because it's evaluated at runtime
Address: TypeAlias = Union[
str, bytes, Tuple[str, int], Tuple[str, int, int], Tuple[str, int, int, int]
Expand Down

0 comments on commit 4e62939

Please sign in to comment.