You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A quick search shows that ByteSendStream and its subclasses are probably affected due to send as well as maybe UDPSocket.sendto. Things may be a bit hairier with generics like UnreliableObjectStream[bytes] or the generics wrapping the packet types.
I think Path.write_bytes may have been the easy one :-/
It looks like the underlying trio and asyncio stubs already use some form of union of bytes | bytearray | memoryview or some variant of Buffer in these function calls.
Not sure how painful it would be to define a typevar that unions these byte like objects or if switching to Buffer is the right move (i'm still pretty type dumb).
Also not sure if this is worth chasing and ripping the bandaid off or doing piecemeal as issues come up. Users do have the option of disabling the mypy check or pinning to a lower mypy version but they may be loathe to do that since it could be masking issues .
Activity
Widen Path.write_bytes data param to ReadableBuffer (#1136)
vfazio commentedon May 7, 2026
This is fun, all I have to do now is create an issue and let the Ai bots spin up PRs to fix them
agronholm commentedon May 7, 2026
Well, I don't care who writes the fixes so long as they play by the rules and respond to reviews.
vfazio commentedon May 7, 2026
I'll try to take some time this weekend to see if there are other places that need to be widened unless that analysis was already done in the PR.
vfazio commentedon May 7, 2026
A quick search shows that
ByteSendStreamand its subclasses are probably affected due tosendas well as maybeUDPSocket.sendto. Things may be a bit hairier with generics likeUnreliableObjectStream[bytes]or the generics wrapping the packet types.I think
Path.write_bytesmay have been the easy one :-/It looks like the underlying trio and asyncio stubs already use some form of union of
bytes | bytearray | memoryviewor some variant ofBufferin these function calls.Not sure how painful it would be to define a typevar that unions these byte like objects or if switching to Buffer is the right move (i'm still pretty type dumb).
Also not sure if this is worth chasing and ripping the bandaid off or doing piecemeal as issues come up. Users do have the option of disabling the mypy check or pinning to a lower mypy version but they may be loathe to do that since it could be masking issues .