python-trio / trio-typing

Type hints for Trio and related projects
Other
27 stars 14 forks source link

Argument local_address for open_tcp_stream is missing #32

Closed joernheissler closed 2 years ago

joernheissler commented 3 years ago

The stub for open_tcp_stream is missing the local_address argument. I tried adding it as Optional[AnyStr] but this has the interesting effect that host and local_address must be the same type afterwards, e.g. await trio.open_tcp_stream(b"1.2.3.4", 567, local_address="8.9.10.11") is not possible according to mypy even though socket.connect and socket.bind accept both bytes and strs.

oremanj commented 2 years ago

AnyStr means "any string, but the same kind everywhere it appears". I uploaded #46 which uses the more flexible Union[str, bytes] instead.