Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 frommypy_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] |
sterliakov commentedMay 12, 2025
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 |
772cd0c intopython:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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'sdocumentation). This PR also includes tests, for --strict and also for no flags.