Skip to content
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

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

Open
jakkdl opened this issue Sep 24, 2024 · 0 comments · May be fixed by #3151
Open

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

jakkdl opened this issue Sep 24, 2024 · 0 comments · May be fixed by #3151
Labels
good first issue typing Adding static types to trio's interface

Comments

@jakkdl
Copy link
Member

jakkdl commented Sep 24, 2024

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?

@A5rocks A5rocks added the typing Adding static types to trio's interface label Sep 27, 2024
@A5rocks A5rocks linked a pull request Dec 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue typing Adding static types to trio's interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants