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
Please add a command line and configuration parameter --disable-bytes-alias to avoid Mypy to consider bytes an alias for bytearray and memoryview.
Pitch
In the documentation of typing.ByteString, a little footnote probably, entered by the author's cat walking on the keyboard and entering random keypresses, says that bytes can be used as a shorthand to represent unrelated types such as memoryview, which have a different interface. See #12643.
As a result, it is not possible to obtain reliable code analysis on code using different ByteString types, such as:
Mypy will report that the if branch will never be executed, then it will proceed to complain that memoryview doesn't have a decode() method.
It would be nice to have this behaviour deprecated and eventually removed and forgotten (no harm intended to the cat). However, as this is a long process, it would be nice to give developers the possibility to disable this ill-thought rule sooner.
The text was updated successfully, but these errors were encountered:
Let's keep this one open. #13952 does implement this, but currently only for testing purposes, not as a documented feature of mypy. I don't recommend users rely on its existence or behaviour for now.
Feature
Please add a command line and configuration parameter
--disable-bytes-alias
to avoid Mypy to considerbytes
an alias forbytearray
andmemoryview
.Pitch
In the documentation of
typing.ByteString
, a little footnote probably, entered by the author's cat walking on the keyboard and entering random keypresses, says thatbytes
can be used as a shorthand to represent unrelated types such asmemoryview
, which have a different interface. See #12643.As a result, it is not possible to obtain reliable code analysis on code using different
ByteString
types, such as:Mypy will report that the
if
branch will never be executed, then it will proceed to complain thatmemoryview
doesn't have adecode()
method.It would be nice to have this behaviour deprecated and eventually removed and forgotten (no harm intended to the cat). However, as this is a long process, it would be nice to give developers the possibility to disable this ill-thought rule sooner.
The text was updated successfully, but these errors were encountered: