Skip to content

Update SocketType.recv (&other) signatures to use PEP570 #3094

Closed
@jakkdl

Description

@jakkdl

python/typeshed#11250 changed the signatures of SocketType.recv and friends, so it should now be possible to change

trio/src/trio/_socket.py

Lines 1115 to 1129 in 4e979bf

# Not possible to typecheck with a Callable (due to DefaultArg), nor with a
# callback Protocol (https://github.com/python/typing/discussions/1040)
# but this seems to work. If not explicitly defined then pyright --verifytypes will
# complain about AmbiguousType
if TYPE_CHECKING:
def recv(__self, __buflen: int, __flags: int = 0) -> Awaitable[bytes]: ...
# _make_simple_sock_method_wrapper is typed, so this checks that the above is correct
# this requires that we refrain from using `/` to specify pos-only
# args, or mypy thinks the signature differs from typeshed.
recv = _make_simple_sock_method_wrapper(
_stdlib_socket.socket.recv,
_core.wait_readable,
)

although I'm surprised that mypy haven't started complaining from bumping typeshed. Maybe they did some backwards compatibility thing? Or haven't bumped typeshed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions