Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@wyattscarpenter
Copy link
Contributor

@wyattscarpenterwyattscarpenter commentedMay 7, 2025
edited
Loading

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.

jorenham reacted with thumbs up emoji
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.
@wyattscarpenterwyattscarpenter marked this pull request as draftMay 8, 2025 00:06
@github-actions

This comment has been minimized.

@wyattscarpenterwyattscarpenter marked this pull request as ready for reviewMay 8, 2025 01:42
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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
Copy link
Collaborator

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--strict group IMO as it can actually flag unsound code and isn't linter-ish. Given the desire to enable it in 2.0, I think adding this flag to--strict will increase its exposure before it's too late.

wyattscarpenter reacted with heart emoji

@JukkaLJukkaL merged commit772cd0c intopython:masterMay 13, 2025
18 checks passed
@wyattscarpenterwyattscarpenter deleted the add_strict-bytes_to_strict branchMay 13, 2025 09:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@sterliakovsterliakovsterliakov approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@wyattscarpenter@sterliakov@JukkaL

[8]ページ先頭

©2009-2025 Movatter.jp