-
-
Notifications
You must be signed in to change notification settings - Fork 3k
add --strict-bytes to --strict #19049
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
add --strict-bytes to --strict #19049
Conversation
This is a check that ensures static correctness, so it is useful to have here. Unlike making this the default behavior eventually in 2.0 (which we are also planning to do), it can be added to --strict immediately due to --strict having looser backwards-compatibility requirements (or so I interpret its documentation). This commit also includes tests.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/network_layer.py:351: error: Argument 1 to "recv_into" of "NetworkingInterface" has incompatible type "memoryview[int]"; expected "bytes" [arg-type]
+ pymongo/network_layer.py:767: error: Argument 1 to "decompress" has incompatible type "memoryview[int]"; expected "bytes" [arg-type]
+ pymongo/network_layer.py:769: error: Incompatible types in assignment (expression has type "memoryview[int]", variable has type "bytes") [assignment]
+ pymongo/message.py:738: error: Argument 1 to "_inflate_bson" has incompatible type "memoryview[int]"; expected "bytes" [arg-type]
+ pymongo/asynchronous/encryption.py:212: error: Incompatible types in assignment (expression has type "memoryview[int]", variable has type "bytes") [assignment]
boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/write.py:67: error: Argument "data" to "Request" has incompatible type "Union[bytes, bytearray, memoryview[int]]"; expected "Union[Dict[str, Any], bytes, None]" [arg-type]
+ boostedblob/write.py:88: error: Argument "data" to "Request" has incompatible type "Union[bytes, bytearray, memoryview[int]]"; expected "Union[Dict[str, Any], bytes, None]" [arg-type]
+ boostedblob/write.py:411: error: Argument "data" to "Request" has incompatible type "Union[bytes, bytearray, memoryview[int]]"; expected "Union[Dict[str, Any], bytes, None]" [arg-type]
bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/core/serialization.py: note: In member "_decode_bytes" of class "Deserializer":
+ src/bokeh/core/serialization.py:618:16: error: Incompatible return value type (got "bytes | memoryview[int]", expected "bytes") [return-value]
websockets (https://github.com/aaugustin/websockets)
+ src/websockets/streams.py:52: error: Incompatible return value type (got "bytearray", expected "bytes") [return-value]
+ src/websockets/streams.py:75: error: Incompatible return value type (got "bytearray", expected "bytes") [return-value]
+ src/websockets/streams.py:97: error: Incompatible return value type (got "bytearray", expected "bytes") [return-value]
+ src/websockets/frames.py:174: error: Argument 1 to "parse" of "Close" has incompatible type "bytes | bytearray | memoryview[int]"; expected "bytes" [arg-type]
+ src/websockets/frames.py:328: error: Argument 1 to "apply_mask" has incompatible type "bytes | bytearray | memoryview[int]"; expected "bytes" [arg-type]
+ src/websockets/frames.py:330: error: Incompatible types in assignment (expression has type "bytes | bytearray | memoryview[int]", variable has type "bytes") [assignment]
+ src/websockets/protocol.py:706: error: Argument 1 to "parse" of "Close" has incompatible type "bytes | bytearray | memoryview[int]"; expected "bytes" [arg-type]
+ src/websockets/extensions/permessage_deflate.py:137: error: Incompatible types in assignment (expression has type "bytes | bytearray | memoryview[int]", variable has type "bytes") [assignment]
+ src/websockets/extensions/permessage_deflate.py:194: error: Incompatible types in assignment (expression has type "memoryview[int]", variable has type "bytes") [assignment]
+ src/websockets/asyncio/messages.py:246: error: Incompatible types in "yield" (actual type "bytes | bytearray | memoryview[int]", expected type "str | bytes") [misc]
+ src/websockets/asyncio/messages.py:260: error: Incompatible types in "yield" (actual type "bytes | bytearray | memoryview[int]", expected type "str | bytes") [misc]
+ src/websockets/asyncio/connection.py:487: error: Argument 1 to "send_text" of "Protocol" has incompatible type "bytes | memoryview[Any]"; expected "bytes" [arg-type]
+ src/websockets/asyncio/connection.py:489: error: Argument 1 to "send_binary" of "Protocol" has incompatible type "bytes | memoryview[Any]"; expected "bytes" [arg-type]
+ src/websockets/sync/messages.py:258: error: Incompatible types in "yield" (actual type "bytes | bytearray | memoryview[int]", expected type "str | bytes") [misc]
+ src/websockets/sync/messages.py:269: error: Incompatible types in "yield" (actual type "bytes | bytearray | memoryview[int]", expected type "str | bytes") [misc]
+ src/websockets/legacy/framing.py:117: error: Argument 3 to "Frame" has incompatible type "bytes | bytearray | memoryview[int]"; expected "bytes" [arg-type]
+ src/websockets/sync/connection.py:486: error: Argument 1 to "send_text" of "Protocol" has incompatible type "bytes | memoryview[Any]"; expected "bytes" [arg-type]
+ src/websockets/sync/connection.py:488: error: Argument 1 to "send_binary" of "Protocol" has incompatible type "bytes | memoryview[Any]"; expected "bytes" [arg-type]
+ src/websockets/legacy/protocol.py:631: error: Argument 1 to "prepare_data" has incompatible type "str | bytes | memoryview[Any]"; expected "str | bytes" [arg-type]
+ src/websockets/sync/client.py:645: error: Argument 1 to "send" of "SSLSSLSocket" has incompatible type "memoryview[int]"; expected "bytes" [arg-type]
python-chess (https://github.com/niklasf/python-chess)
+ chess/gaviota.py:1738: error: Incompatible types in assignment (expression has type "bytearray", variable has type "bytes") [assignment]
werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/sansio/multipart.py:174: error: Argument 1 to "_parse_headers" of "MultipartDecoder" has incompatible type "bytearray"; expected "bytes" [arg-type]
+ src/werkzeug/sansio/multipart.py:213: error: Argument 1 to "_parse_data" of "MultipartDecoder" has incompatible type "bytearray"; expected "bytes" [arg-type]
+ src/werkzeug/sansio/multipart.py:220: error: Argument 1 to "_parse_data" of "MultipartDecoder" has incompatible type "bytearray"; expected "bytes" [arg-type]
|
I think this is a good suggestion. Probably needs a visible changelog entry (not only in "other changes" list), but this flag really belongs to |
This is a check that ensures static correctness, so it is useful to have in --strict. Unlike making this the default behavior eventually in 2.0, which we are also planning to do, it can be added to --strict immediately due to --strict having looser backwards-compatibility requirements (or so I interpret --strict's documentation). This PR also includes tests, for --strict and also for no flags.