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
If I understand the buffer situation correctly, bytes | ReadOnlyBuffer is equivalent to ReadOnlyBuffer, because typeshed claims that bytes implements __buffer__ on all Python versions.
It feels like a good idea to detect unions where bytes types are used like this, similar to Literal[1] | int and other checks we already have. But it feels like a bad idea to make flake8-pyi aware of _typeshed.ReadOnlyBuffer etc and their subtyping rules. I'm not sure.
The text was updated successfully, but these errors were encountered:
It feels like a good idea to detect unions where bytes types are used like this, similar to Literal[1] | int and other checks we already have. But it feels like a bad idea to make flake8-pyi aware of _typeshed.ReadOnlyBuffer etc and their subtyping rules. I'm not sure.
A general-purpose way of detecting redundant unions could only ever be implemented by a type checker, since they're much better equipped to resolve imports across modules than we'll ever be. We have a much simpler design that only analyses a module at a time, and I'd like to keep it that way (I'm not sure flake8's plugin system even would allow us to analyse multiple modules at a time). So we'll need to weigh up whether it's worth special-casing these specific types from _typeshed or not.
Currently this annotation doesn't cause a lint error: (taken from python/typeshed#10432 )
If I understand the buffer situation correctly,
bytes | ReadOnlyBuffer
is equivalent toReadOnlyBuffer
, because typeshed claims thatbytes
implements__buffer__
on all Python versions.It feels like a good idea to detect unions where bytes types are used like this, similar to
Literal[1] | int
and other checks we already have. But it feels like a bad idea to make flake8-pyi aware of_typeshed.ReadOnlyBuffer
etc and their subtyping rules. I'm not sure.The text was updated successfully, but these errors were encountered: