Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Dec 30, 2024

For mypy v2

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

aioredis (https://github.com/aio-libs/aioredis)
+ aioredis/connection.py:952: error: Argument 1 to "append" of "list" has incompatible type "bytes | memoryview[int]"; expected "bytes"  [arg-type]
+ aioredis/connection.py:981: error: Subclass of "bytes" and "memoryview[Any]" cannot exist: "memoryview" is final  [unreachable]
+ aioredis/connection.py:987: error: Subclass of "bytes" and "memoryview[Any]" cannot exist: "memoryview" is final  [unreachable]

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/dns.py:412: error: Argument 1 to "unpack_from_with_compression" has incompatible type "bytes | bytearray"; expected "bytes"  [arg-type]
+ mitmproxy/dns.py:446: error: Argument 1 to "decompress_from_record_data" has incompatible type "bytes | bytearray"; expected "bytes"  [arg-type]
+ mitmproxy/dns.py:449: error: Argument 5 to "ResourceRecord" has incompatible type "bytes | bytearray"; expected "bytes"  [arg-type]
+ mitmproxy/proxy/layers/tls.py:570: error: Argument 1 to "dtls_parse_client_hello" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ mitmproxy/proxy/layers/tls.py:572: error: Argument 1 to "parse_client_hello" has incompatible type "bytearray"; expected "bytes"  [arg-type]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/app.py:246: error: Argument 1 to "verify_signature" has incompatible type "memoryview[int]"; expected "bytes"  [arg-type]
+ steam/state.py:3004: error: Argument 1 to "receive" of "SteamWebSocket" has incompatible type "bytearray"; expected "bytes"  [arg-type]

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/util/ssltransport.py:108: error: Argument 1 to "send" of "SSLTransport" has incompatible type "memoryview[int]"; expected "bytes"  [arg-type]
+ src/urllib3/response.py:409: error: Incompatible return value type (got "bytes | memoryview[bytes]", expected "bytes")  [return-value]
+ test/test_ssltransport.py:57: error: Non-overlapping equality check (left operand type: "bytearray", right operand type: "str | bytes")  [comparison-overlap]
+ test/test_ssltransport.py:548: error: Argument 1 to "sendall" of "SSLTransport" has incompatible type "bytearray"; expected "bytes"  [arg-type]

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/internal/test_visibility/coverage_lines.py:74: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]

trio (https://github.com/python-trio/trio)
+ src/trio/_unix_pipes.py:130: error: Argument 1 of "send_all" is incompatible with supertype "trio._abc.SendStream"; supertype defines the argument type as "bytes | bytearray | memoryview[int]"  [override]
+ src/trio/_unix_pipes.py:130: note: This violates the Liskov substitution principle
+ src/trio/_unix_pipes.py:130: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ src/trio/_highlevel_generic.py:118: error: Incompatible return value type (got "bytes | bytearray", expected "bytes")  [return-value]
+ src/trio/_tests/test_testing.py:421: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ src/trio/_tests/test_ssl.py:255: error: Argument 1 of "send_all" is incompatible with supertype "trio._abc.SendStream"; supertype defines the argument type as "bytes | bytearray | memoryview[int]"  [override]
+ src/trio/_tests/test_ssl.py:255: note: This violates the Liskov substitution principle
+ src/trio/_tests/test_ssl.py:255: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ src/trio/_tests/test_dtls.py:501: error: No overload variant of "sendto" of "SocketType" matches argument types "Sequence[int]", "tuple[str, int]"  [call-overload]
+ src/trio/_tests/test_dtls.py:501: note: Possible overload variants:
+ src/trio/_tests/test_dtls.py:501: note:     def sendto(self, Buffer, tuple[object, ...] | str | Buffer, /) -> Coroutine[Any, Any, int]
+ src/trio/_tests/test_dtls.py:501: note:     def sendto(self, Buffer, int, tuple[object, ...] | str | Buffer, /) -> Coroutine[Any, Any, int]
+ src/trio/_tests/test_dtls.py:535: error: Argument "payload" to "evolve" of "UDPPacket" has incompatible type "bytearray"; expected "bytes"  [arg-type]

pycryptodome (https://github.com/Legrandin/pycryptodome)
+ lib/Crypto/Cipher/_mode_kw.py:25: error: Incompatible return value type (got "bytes | bytearray", expected "bytes")  [return-value]
+ lib/Crypto/Cipher/_mode_kw.py:39: error: Argument 1 to "strxor" has incompatible type "bytes | bytearray"; expected "bytes"  [arg-type]
+ lib/Crypto/Cipher/_mode_kw.py:43: error: Incompatible return value type (got "bytes | bytearray", expected "bytes")  [return-value]

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/file.py: note: In function "gdb_memtox_inverse":
+ pwndbg/aglib/file.py:271: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/macho.py: note: In member "_walk" of class "_RawTrie":
+ pwndbg/aglib/macho.py:90: error: Argument 2 has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/macho.py: note: In member "keys" of class "DyldSharedCacheHashSet":
+ pwndbg/aglib/macho.py:406: error: Incompatible types in "yield" (actual type "bytearray", expected type "bytes")  [misc]
+ pwndbg/aglib/macho.py: note: In member "images" of class "DyldSharedCache":
+ pwndbg/aglib/macho.py:578: error: Incompatible types in "yield" (actual type "tuple[bytearray, Any]", expected type "tuple[bytes, int]")  [misc]
+ pwndbg/aglib/objc.py: note: In member "name" of class "_ClassRoPtr":
+ pwndbg/aglib/objc.py:124: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "demangled_name" of class "_ClassRwExtPtr":
+ pwndbg/aglib/objc.py:190: error: Incompatible return value type (got "bytearray", expected "bytes | None")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "name" of class "InstanceVariable":
+ pwndbg/aglib/objc.py:656: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "typename" of class "InstanceVariable":
+ pwndbg/aglib/objc.py:665: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "name" of class "ClassProperty":
+ pwndbg/aglib/objc.py:699: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "value" of class "ClassProperty":
+ pwndbg/aglib/objc.py:706: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "name" of class "Selector":
+ pwndbg/aglib/objc.py:733: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/objc.py: note: In member "types" of class "Method":
+ pwndbg/aglib/objc.py:798: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/commands/hexdump.py: note: In function "hexdump":
+ pwndbg/commands/hexdump.py:164: error: Argument 1 to "format_py" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/commands/hexdump.py:164: error: Argument 1 to "format_c" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/commands/hexdump.py:169: error: Argument 1 to "hexdump" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In function "read_buildversion":
+ pwndbg/aglib/godbg.py:294: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:295: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In function "get_go_version":
+ pwndbg/aglib/godbg.py:325: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In function "read_varint_str":
+ pwndbg/aglib/godbg.py:418: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/godbg.py:425: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/godbg.py: note: In function "read_type_name":
+ pwndbg/aglib/godbg.py:439: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:442: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]
+ pwndbg/aglib/godbg.py: note: In function "_inner_decode_runtime_type":
+ pwndbg/aglib/godbg.py:596: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:688: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:689: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:739: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:744: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:746: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In member "dump" of class "BasicType":
+ pwndbg/aglib/godbg.py:795: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:798: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:800: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:806: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:818: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:819: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:823: error: Argument 1 to "load_int" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:825: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:830: error: Argument 1 to "load_float" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:833: error: Argument 1 to "load_float" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:834: error: Argument 1 to "load_float" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:843: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:844: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In member "dump" of class "SliceType":
+ pwndbg/aglib/godbg.py:910: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:911: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:918: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In member "dump" of class "PointerType":
+ pwndbg/aglib/godbg.py:950: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In member "dump_noswiss" of class "MapType":
+ pwndbg/aglib/godbg.py:1156: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:1190: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py: note: In member "dump_swiss" of class "MapType":
+ pwndbg/aglib/godbg.py:1196: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:1197: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:1211: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:1216: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]
+ pwndbg/aglib/godbg.py:1217: error: Argument 1 to "load_uint" has incompatible type "bytearray"; expected "bytes"  [arg-type]

git-revise (https://github.com/mystor/git-revise)
+ gitrevise/utils.py:127: error: Incompatible return value type (got "bytearray", expected "bytes")  [return-value]

elif self.disable_bytearray_promotion and self.disable_memoryview_promotion:
# forwards compatibility
self.strict_bytes = True
else:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done in #19002 and I don't think that's correct

There is a weird interaction that exists between specifying both --no-strict-bytes and one of these (undocumented) flags, but maybe that is a better fit for more generalised "preset" handling in config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants