-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Open
wyattscarpenter
wants to merge
3
commits into
python:master
Choose a base branch
from
wyattscarpenter:add_strict-bytes_to_strict
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add --strict-bytes to --strict #19049
wyattscarpenter
wants to merge
3
commits into
python:master
from
wyattscarpenter:add_strict-bytes_to_strict
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.