Skip to content

Be strict about arg names in protocol compatibility#21016

Draft
hauntsaninja wants to merge 4 commits intopython:masterfrom
hauntsaninja:protoposonly
Draft

Be strict about arg names in protocol compatibility#21016
hauntsaninja wants to merge 4 commits intopython:masterfrom
hauntsaninja:protoposonly

Conversation

@hauntsaninja
Copy link
Collaborator

Fixes #21014

is_compat = is_subtype(
subtype, supertype, ignore_pos_arg_names=ignore_names, options=options
)
is_compat = is_subtype(subtype, supertype, options=options)
Copy link
Member

Choose a reason for hiding this comment

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

You will need to also remove it from SubtypeContext() ~50 lines below.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@ilevkivskyi
Copy link
Member

OK, as I predicted, situation for protocols is much better, but there is still some fallout, and I am afraid there may be situations like in meson, where just one imprecise type will cause dozens of errors. (Btw @eli-schwartz technically, arguments for count() and index() in ImmutableListProtocol should be positional-only, like in real list).

One thing to help with the situation is to add some kind of a note if subtype has positional-only arguments, while supertype doesn't have any. Otherwise it is hard to spot / in the mismatched signatures. This will also help with LSP.

Anyway, I will leave up to @JukkaL when to merge this. Technically, we don't need to do this is in a major release, since this was a clear false negative. But we should probably still avoid batching too many potential breakages in a single release.

@eli-schwartz
Copy link
Contributor

(Btw @eli-schwartz technically, arguments for count() and index() in ImmutableListProtocol should be positional-only, like in real list).

In the upcoming release we are dropping 3.7 support, and then once master unfreezes we can use PEP 570. Should help here.

@github-actions
Copy link
Contributor

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

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/errors.py:242: error: Incompatible return value type (got "FinishedPGconn", expected "PGconn")  [return-value]
+ psycopg/psycopg/errors.py:242: note: Following member(s) of "FinishedPGconn" have conflicts:
+ psycopg/psycopg/errors.py:242: note:     Expected:
+ psycopg/psycopg/errors.py:242: note:         def change_password(self, user: bytes, passwd: bytes) -> None
+ psycopg/psycopg/errors.py:242: note:     Got:
+ psycopg/psycopg/errors.py:242: note:         def change_password(self, *args: Any) -> Never
+ psycopg/psycopg/errors.py:242: note:     Expected:
+ psycopg/psycopg/errors.py:242: note:         def close_portal(self, name: bytes) -> PGresult
+ psycopg/psycopg/errors.py:242: note:     Got:
+ psycopg/psycopg/errors.py:242: note:         def close_portal(self, *args: Any) -> Never
+ psycopg/psycopg/errors.py:242: note:     <26 more conflict(s) not shown>

tornado (https://github.com/tornadoweb/tornado)
+ tornado/websocket.py:773: error: Incompatible return value type (got "_Compress", expected "_Compressor")  [return-value]
+ tornado/websocket.py:773: note: Following member(s) of "_Compress" have conflicts:
+ tornado/websocket.py:773: note:     Expected:
+ tornado/websocket.py:773: note:         def compress(self, data: bytes) -> bytes
+ tornado/websocket.py:773: note:     Got:
+ tornado/websocket.py:773: note:         def compress(self, Buffer, /) -> bytes
+ tornado/websocket.py:773: note:     Expected:
+ tornado/websocket.py:773: note:         def flush(self, mode: int) -> bytes
+ tornado/websocket.py:773: note:     Got:
+ tornado/websocket.py:773: note:         def flush(self, int = ..., /) -> bytes
+ tornado/websocket.py:810: error: Incompatible return value type (got "_Decompress", expected "_Decompressor")  [return-value]
+ tornado/websocket.py:810: note: Following member(s) of "_Decompress" have conflicts:
+ tornado/websocket.py:810: note:     Expected:
+ tornado/websocket.py:810: note:         def decompress(self, data: bytes, max_length: int) -> bytes
+ tornado/websocket.py:810: note:     Got:
+ tornado/websocket.py:810: note:         def decompress(self, Buffer, /, max_length: int = ...) -> bytes

pylox (https://github.com/sco1/pylox)
+ pylox/resolver.py:63: error: Argument 1 to "accept" of "Stmt" has incompatible type "Resolver"; expected "VisitorProtocol"  [arg-type]
+ pylox/resolver.py:63: note: Following member(s) of "Resolver" have conflicts:
+ pylox/resolver.py:63: note:     Expected:
+ pylox/resolver.py:63: note:         def visit_Block(self, expr: Block) -> Any
+ pylox/resolver.py:63: note:     Got:
+ pylox/resolver.py:63: note:         def visit_Block(self, stmt: Block) -> None
+ pylox/resolver.py:63: note:     Expected:
+ pylox/resolver.py:63: note:         def visit_Break(self, expr: Break) -> Any
+ pylox/resolver.py:63: note:     Got:
+ pylox/resolver.py:63: note:         def visit_Break(self, stmt: Break) -> None
+ pylox/resolver.py:63: note:     <9 more conflict(s) not shown>
+ pylox/resolver.py:63: error: Argument 1 to "accept" of "Expr" has incompatible type "Resolver"; expected "VisitorProtocol"  [arg-type]
+ pylox/resolver.py:63: note: Following member(s) of "Resolver" have conflicts:
+ pylox/resolver.py:63: note:     Expected:
+ pylox/resolver.py:63: note:         def visit_Block(self, expr: Block) -> Any
+ pylox/resolver.py:63: note:     Got:
+ pylox/resolver.py:63: note:         def visit_Block(self, stmt: Block) -> None
+ pylox/resolver.py:63: note:     Expected:
+ pylox/resolver.py:63: note:         def visit_Break(self, expr: Break) -> Any
+ pylox/resolver.py:63: note:     Got:
+ pylox/resolver.py:63: note:         def visit_Break(self, stmt: Break) -> None
+ pylox/interpreter.py:113: error: Argument 1 to "accept" of "Expr" has incompatible type "Interpreter"; expected "VisitorProtocol"  [arg-type]
+ pylox/interpreter.py:113: note: Following member(s) of "Interpreter" have conflicts:
+ pylox/interpreter.py:113: note:     Expected:
+ pylox/interpreter.py:113: note:         def visit_Block(self, expr: Block) -> Any
+ pylox/interpreter.py:113: note:     Got:
+ pylox/interpreter.py:113: note:         def visit_Block(self, stmt: Block) -> None
+ pylox/interpreter.py:113: note:     Expected:
+ pylox/interpreter.py:113: note:         def visit_Break(self, expr: Break) -> Any
+ pylox/interpreter.py:113: note:     Got:
+ pylox/interpreter.py:113: note:         def visit_Break(self, stmt: Break) -> None
+ pylox/interpreter.py:113: note:     <9 more conflict(s) not shown>
+ pylox/interpreter.py:113: error: Argument 1 to "accept" of "Stmt" has incompatible type "Interpreter"; expected "VisitorProtocol"  [arg-type]
+ pylox/interpreter.py:113: note: Following member(s) of "Interpreter" have conflicts:
+ pylox/interpreter.py:113: note:     Expected:
+ pylox/interpreter.py:113: note:         def visit_Block(self, expr: Block) -> Any
+ pylox/interpreter.py:113: note:     Got:
+ pylox/interpreter.py:113: note:         def visit_Block(self, stmt: Block) -> None
+ pylox/interpreter.py:113: note:     Expected:
+ pylox/interpreter.py:113: note:         def visit_Break(self, expr: Break) -> Any
+ pylox/interpreter.py:113: note:     Got:
+ pylox/interpreter.py:113: note:         def visit_Break(self, stmt: Break) -> None

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/compression_utils.py:136:54: error: Argument 1 to "ZLibBackendWrapper" has incompatible type Module; expected "ZLibBackendProtocol"  [arg-type]
+ aiohttp/compression_utils.py:136:54: note: Following member(s) of Module "zlib" have conflicts:
+ aiohttp/compression_utils.py:136:54: note:     Expected:
+ aiohttp/compression_utils.py:136:54: note:         def compressobj(level: int = ..., method: int = ..., wbits: int = ..., memLevel: int = ..., strategy: int = ..., zdict: Buffer | None = ...) -> ZLibCompressObjProtocol
+ aiohttp/compression_utils.py:136:54: note:     Got:
+ aiohttp/compression_utils.py:136:54: note:         def compressobj(level: int = ..., method: int = ..., wbits: int = ..., memLevel: int = ..., strategy: int = ..., zdict: Buffer | None = ...) -> _Compress
+ aiohttp/compression_utils.py:136:54: note:     Expected:
+ aiohttp/compression_utils.py:136:54: note:         def decompressobj(wbits: int = ..., zdict: Buffer = ...) -> ZLibDecompressObjProtocol
+ aiohttp/compression_utils.py:136:54: note:     Got:
+ aiohttp/compression_utils.py:136:54: note:         def decompressobj(wbits: int = ..., zdict: Buffer = ...) -> _Decompress

meson (https://github.com/mesonbuild/meson)
+ mesonbuild/utils/universal.py:238:26: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str] | None")  [assignment]
+ mesonbuild/utils/universal.py:241:26: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str] | None")  [assignment]
+ mesonbuild/utils/universal.py:244:26: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str] | None")  [assignment]
+ mesonbuild/utils/universal.py:721:12: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/utils/universal.py:721:12: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/utils/universal.py:721:12: note:     Expected:
+ mesonbuild/utils/universal.py:721:12: note:         def count(self, item: str) -> int
+ mesonbuild/utils/universal.py:721:12: note:     Got:
+ mesonbuild/utils/universal.py:721:12: note:         def count(self, str, /) -> int
+ mesonbuild/utils/universal.py:721:12: note:     Expected:
+ mesonbuild/utils/universal.py:721:12: note:         def index(self, item: str) -> int
+ mesonbuild/utils/universal.py:721:12: note:     Got:
+ mesonbuild/utils/universal.py:721:12: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/compilers/mixins/apple.py:27:52: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str]")  [assignment]
+ mesonbuild/compilers/mixins/apple.py:27:52: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/compilers/mixins/apple.py:27:52: note:     Expected:
+ mesonbuild/compilers/mixins/apple.py:27:52: note:         def count(self, item: str) -> int
+ mesonbuild/compilers/mixins/apple.py:27:52: note:     Got:
+ mesonbuild/compilers/mixins/apple.py:27:52: note:         def count(self, str, /) -> int
+ mesonbuild/compilers/mixins/apple.py:27:52: note:     Expected:
+ mesonbuild/compilers/mixins/apple.py:27:52: note:         def index(self, item: str) -> int
+ mesonbuild/compilers/mixins/apple.py:27:52: note:     Got:
+ mesonbuild/compilers/mixins/apple.py:27:52: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/envconfig.py:100:5: error: Dict entry 0 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:101:5: error: Dict entry 1 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:102:5: error: Dict entry 2 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:103:5: error: Dict entry 3 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:104:5: error: Dict entry 4 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:105:5: error: Dict entry 5 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:106:5: error: Dict entry 6 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:107:5: error: Dict entry 7 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:108:5: error: Dict entry 8 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:109:5: error: Dict entry 9 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:110:5: error: Dict entry 10 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:113:5: error: Dict entry 11 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:114:5: error: Dict entry 12 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:115:5: error: Dict entry 13 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:116:5: error: Dict entry 14 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:117:5: error: Dict entry 15 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:118:5: error: Dict entry 16 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:119:5: error: Dict entry 17 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:125:5: error: Dict entry 0 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:126:5: error: Dict entry 1 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:127:5: error: Dict entry 2 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:128:5: error: Dict entry 3 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:129:5: error: Dict entry 4 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:130:5: error: Dict entry 5 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:131:5: error: Dict entry 6 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:132:5: error: Dict entry 7 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:133:5: error: Dict entry 8 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:134:5: error: Dict entry 9 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:135:5: error: Dict entry 10 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:136:5: error: Dict entry 11 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:139:5: error: Dict entry 12 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:140:5: error: Dict entry 13 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:141:5: error: Dict entry 14 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:142:5: error: Dict entry 15 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:143:5: error: Dict entry 16 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:144:5: error: Dict entry 17 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:152:5: error: Dict entry 0 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:153:5: error: Dict entry 1 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:154:5: error: Dict entry 2 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/envconfig.py:155:5: error: Dict entry 3 has incompatible type "str": "list[str]"; expected "str": "ImmutableListProtocol[str]"  [dict-item]
+ mesonbuild/compilers/mixins/gnu.py:321:16: error: Incompatible return value type (got "list[Never]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/compilers/mixins/gnu.py:321:16: note: Following member(s) of "list[Never]" have conflicts:
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:     Expected:
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:         def count(self, item: str) -> int
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:     Got:
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:         def count(self, Never, /) -> int
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:     Expected:
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:         def index(self, item: str) -> int
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:     Got:
+ mesonbuild/compilers/mixins/gnu.py:321:16: note:         def index(self, Never, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/compilers/mixins/gnu.py:348:12: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/compilers/mixins/gnu.py:348:12: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:     Expected:
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:         def count(self, item: str) -> int
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:     Got:
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:         def count(self, str, /) -> int
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:     Expected:
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:         def index(self, item: str) -> int
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:     Got:
+ mesonbuild/compilers/mixins/gnu.py:348:12: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/compilers/mixins/clike.py:210:20: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/compilers/mixins/clike.py:210:20: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/compilers/mixins/clike.py:210:20: note:     Expected:
+ mesonbuild/compilers/mixins/clike.py:210:20: note:         def count(self, item: str) -> int
+ mesonbuild/compilers/mixins/clike.py:210:20: note:     Got:
+ mesonbuild/compilers/mixins/clike.py:210:20: note:         def count(self, str, /) -> int
+ mesonbuild/compilers/mixins/clike.py:210:20: note:     Expected:
+ mesonbuild/compilers/mixins/clike.py:210:20: note:         def index(self, item: str) -> int
+ mesonbuild/compilers/mixins/clike.py:210:20: note:     Got:
+ mesonbuild/compilers/mixins/clike.py:210:20: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/compilers/mixins/clike.py:242:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/compilers/mixins/clike.py:242:16: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/compilers/mixins/clike.py:242:16: note:     Expected:
+ mesonbuild/compilers/mixins/clike.py:242:16: note:         def count(self, item: str) -> int
+ mesonbuild/compilers/mixins/clike.py:242:16: note:     Got:
+ mesonbuild/compilers/mixins/clike.py:242:16: note:         def count(self, str, /) -> int
+ mesonbuild/compilers/mixins/clike.py:242:16: note:     Expected:
+ mesonbuild/compilers/mixins/clike.py:242:16: note:         def index(self, item: str) -> int
+ mesonbuild/compilers/mixins/clike.py:242:16: note:     Got:
+ mesonbuild/compilers/mixins/clike.py:242:16: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/compilers/mixins/clike.py:256:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/compilers/mixins/clike.py:256:16: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/compilers/mixins/clike.py:256:16: note:     Expected:
+ mesonbuild/compilers/mixins/clike.py:256:16: note:         def count(self, item: str) -> int
+ mesonbuild/compilers/mixins/clike.py:256:16: note:     Got:
+ mesonbuild/compilers/mixins/clike.py:256:16: note:         def count(self, str, /) -> int
+ mesonbuild/compilers/mixins/clike.py:256:16: note:     Expected:
+ mesonbuild/compilers/mixins/clike.py:256:16: note:         def index(self, item: str) -> int
+ mesonbuild/compilers/mixins/clike.py:256:16: note:     Got:
+ mesonbuild/compilers/mixins/clike.py:256:16: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/environment.py:413:9: error: Need type annotation for "meson_command"  [var-annotated]
+ mesonbuild/dependencies/pkgconfig.py:172:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/dependencies/pkgconfig.py:172:16: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:         def count(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:     Got:
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:         def count(self, str, /) -> int
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:         def index(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:     Got:
+ mesonbuild/dependencies/pkgconfig.py:172:16: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/dependencies/pkgconfig.py:189:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/dependencies/pkgconfig.py:189:16: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:         def count(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:     Got:
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:         def count(self, str, /) -> int
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:         def index(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:     Got:
+ mesonbuild/dependencies/pkgconfig.py:189:16: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/dependencies/pkgconfig.py:215:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/dependencies/pkgconfig.py:215:16: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:         def count(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:     Got:
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:         def count(self, str, /) -> int
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:         def index(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:     Got:
+ mesonbuild/dependencies/pkgconfig.py:215:16: note:         def index(self, str, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/dependencies/pkgconfig.py:437:53: error: Argument 1 to "_convert_mingw_paths" of "PkgConfigDependency" has incompatible type "list[str]"; expected "ImmutableListProtocol[str]"  [arg-type]
+ mesonbuild/dependencies/pkgconfig.py:437:53: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/dependencies/pkgconfig.py:437:53: note:     Expected:
+ mesonbuild/dependencies/pkgconfig.py:437:53: note:         def count(self, item: str) -> int
+ mesonbuild/dependencies/pkgconfig.py:437:53: note:     Got:

... (truncated 96 lines) ...

zulip (https://github.com/zulip/zulip)
+ zerver/lib/upload/local.py:117: error: Argument "reader" to "StreamingSourceWithSize" has incompatible type "Callable[[], BufferedReader[_BufferedReaderStream]]"; expected "Callable[[], ReadableStream]"  [arg-type]
+ zerver/lib/upload/local.py:117: error: Incompatible return value type (got "BufferedReader[_BufferedReaderStream]", expected "ReadableStream")  [return-value]
+ zerver/lib/upload/local.py:117: note: Following member(s) of "BufferedReader[_BufferedReaderStream]" have conflicts:
+ zerver/lib/upload/local.py:117: note:     Expected:
+ zerver/lib/upload/local.py:117: note:         def read(self, size: int = ...) -> bytes
+ zerver/lib/upload/local.py:117: note:     Got:
+ zerver/lib/upload/local.py:117: note:         def read(self, int | None = ..., /) -> bytes

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/specs/openapi/adapter/security.py: note: In function "build_auth_provider":
+ src/schemathesis/specs/openapi/adapter/security.py:304: error: Incompatible return value type (got "ApiKeyAuthProvider", expected "AuthProvider[Any]")  [return-value]
+ src/schemathesis/specs/openapi/adapter/security.py:304: note: Following member(s) of "ApiKeyAuthProvider" have conflicts:
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:     Expected:
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:     Got:
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:         def get(self, _: Case, __: AuthContext) -> str
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:     Expected:
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:     Got:
+ src/schemathesis/specs/openapi/adapter/security.py:304: note:         def set(self, case: Case, data: str, __: AuthContext) -> None
+ src/schemathesis/specs/openapi/adapter/security.py:307: error: Incompatible return value type (got "HttpBasicAuthProvider", expected "AuthProvider[Any]")  [return-value]
+ src/schemathesis/specs/openapi/adapter/security.py:307: note: Following member(s) of "HttpBasicAuthProvider" have conflicts:
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:     Expected:
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:     Got:
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:         def get(self, _: Case, __: AuthContext) -> tuple[str, str]
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:     Expected:
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:     Got:
+ src/schemathesis/specs/openapi/adapter/security.py:307: note:         def set(self, case: Case, data: tuple[str, str], __: AuthContext) -> None
+ src/schemathesis/specs/openapi/adapter/security.py:310: error: Incompatible return value type (got "HttpBearerAuthProvider", expected "AuthProvider[Any]")  [return-value]
+ src/schemathesis/specs/openapi/adapter/security.py:310: note: Following member(s) of "HttpBearerAuthProvider" have conflicts:
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:     Expected:
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:     Got:
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:         def get(self, _: Case, __: AuthContext) -> str
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:     Expected:
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:     Got:
+ src/schemathesis/specs/openapi/adapter/security.py:310: note:         def set(self, case: Case, data: str, __: AuthContext) -> None
+ src/schemathesis/auths.py: note: In member "set_from_requests" of class "AuthStorage":
+ src/schemathesis/auths.py:343: error: Argument 1 to "append" of "list" has incompatible type "SelectiveAuthProvider[Never]"; expected "AuthProvider[Any]"  [arg-type]
+ src/schemathesis/auths.py:343: note: Following member(s) of "SelectiveAuthProvider[Never]" have conflicts:
+ src/schemathesis/auths.py:343: note:     Expected:
+ src/schemathesis/auths.py:343: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/auths.py:343: note:     Got:
+ src/schemathesis/auths.py:343: note:         def get(self, case: Case, context: AuthContext) -> None
+ src/schemathesis/auths.py:343: note:     Expected:
+ src/schemathesis/auths.py:343: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/auths.py:343: note:     Got:
+ src/schemathesis/auths.py:343: note:         def set(self, case: Case, data: Never, context: AuthContext) -> None
+ src/schemathesis/auths.py:343: error: Argument "provider" to "SelectiveAuthProvider" has incompatible type "RequestsAuth[Never]"; expected "AuthProvider[Any]"  [arg-type]
+ src/schemathesis/auths.py:343: note: Following member(s) of "RequestsAuth[Never]" have conflicts:
+ src/schemathesis/auths.py:343: note:     Expected:
+ src/schemathesis/auths.py:343: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/auths.py:343: note:     Got:
+ src/schemathesis/auths.py:343: note:         def get(self, _: Case, __: AuthContext) -> None
+ src/schemathesis/auths.py:343: note:     Expected:
+ src/schemathesis/auths.py:343: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/auths.py:343: note:     Got:
+ src/schemathesis/auths.py:343: note:         def set(self, case: Case, _: Never, __: AuthContext) -> None
+ src/schemathesis/auths.py: note: In member "_set_provider" of class "AuthStorage":
+ src/schemathesis/auths.py:371: error: Incompatible types in assignment (expression has type "CachingAuthProvider[Never]", variable has type "AuthProvider[Any]")  [assignment]
+ src/schemathesis/auths.py:371: note: Following member(s) of "CachingAuthProvider[Never]" have conflicts:
+ src/schemathesis/auths.py:371: note:     Expected:
+ src/schemathesis/auths.py:371: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/auths.py:371: note:     Got:
+ src/schemathesis/auths.py:371: note:         def get(self, case: Case, context: AuthContext) -> None
+ src/schemathesis/auths.py:371: note:     Expected:
+ src/schemathesis/auths.py:371: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/auths.py:371: note:     Got:
+ src/schemathesis/auths.py:371: note:         def set(self, case: Case, data: Never, context: AuthContext) -> None
+ src/schemathesis/auths.py:373: error: Incompatible types in assignment (expression has type "KeyedCachingAuthProvider[Never]", variable has type "AuthProvider[Any]")  [assignment]
+ src/schemathesis/auths.py:373: note: Following member(s) of "KeyedCachingAuthProvider[Never]" have conflicts:
+ src/schemathesis/auths.py:373: note:     Expected:
+ src/schemathesis/auths.py:373: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/auths.py:373: note:     Got:
+ src/schemathesis/auths.py:373: note:         def get(self, case: Case, context: AuthContext) -> None
+ src/schemathesis/auths.py:373: note:     Expected:
+ src/schemathesis/auths.py:373: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/auths.py:373: note:     Got:
+ src/schemathesis/auths.py:373: note:         def set(self, case: Case, data: Never, context: AuthContext) -> None
+ src/schemathesis/auths.py:380: error: Incompatible types in assignment (expression has type "SelectiveAuthProvider[Never]", variable has type "AuthProvider[Any]")  [assignment]
+ src/schemathesis/auths.py:380: note: Following member(s) of "SelectiveAuthProvider[Never]" have conflicts:
+ src/schemathesis/auths.py:380: note:     Expected:
+ src/schemathesis/auths.py:380: note:         def get(self, case: Case, ctx: AuthContext) -> Any | None
+ src/schemathesis/auths.py:380: note:     Got:
+ src/schemathesis/auths.py:380: note:         def get(self, case: Case, context: AuthContext) -> None
+ src/schemathesis/auths.py:380: note:     Expected:
+ src/schemathesis/auths.py:380: note:         def set(self, case: Case, data: Any, ctx: AuthContext) -> None
+ src/schemathesis/auths.py:380: note:     Got:
+ src/schemathesis/auths.py:380: note:         def set(self, case: Case, data: Never, context: AuthContext) -> None

operator (https://github.com/canonical/operator)
- ops/pebble.py:3544: error: Unused "type: ignore" comment  [unused-ignore]

core (https://github.com/home-assistant/core)
+ homeassistant/loader.py:1504: error: Argument "cache" to "_resolve_integrations_dependencies" has incompatible type "dict[Never, Never]"; expected "_ResolveDependenciesCacheProtocol"  [arg-type]
+ homeassistant/loader.py:1504: note: Following member(s) of "dict[Never, Never]" have conflicts:
+ homeassistant/loader.py:1504: note:     Expected:
+ homeassistant/loader.py:1504: note:         def __setitem__(self, Integration, set[str] | Exception, /) -> None
+ homeassistant/loader.py:1504: note:     Got:
+ homeassistant/loader.py:1504: note:         def __setitem__(self, Never, Never, /) -> None
+ homeassistant/loader.py:1504: note:     Expected:
+ homeassistant/loader.py:1504: note:         def get(self, itg: Integration) -> set[str] | Exception | None
+ homeassistant/loader.py:1504: note:     Got:
+ homeassistant/loader.py:1504: note:         @overload
+ homeassistant/loader.py:1504: note:         def get(self, Never, None = ..., /) -> None
+ homeassistant/loader.py:1504: note:         @overload
+ homeassistant/loader.py:1504: note:         def get(self, Never, Never, /) -> Never
+ homeassistant/loader.py:1504: note:         @overload
+ homeassistant/loader.py:1504: note:         def [_T] get(self, Never, _T, /) -> _T
+ homeassistant/components/zha/__init__.py:120: error: Argument 3 to "async_register_firmware_info_provider" has incompatible type Module; expected "SyncHardwareFirmwareInfoModule | AsyncHardwareFirmwareInfoModule"  [arg-type]
+ homeassistant/components/zha/__init__.py:120: note: Following member(s) of Module "homeassistant.components.zha.homeassistant_hardware" have conflicts:
+ homeassistant/components/zha/__init__.py:120: note:     Expected:
+ homeassistant/components/zha/__init__.py:120: note:         def get_firmware_info(hass: HomeAssistant, entry: ConfigEntry[Any]) -> FirmwareInfo | None
+ homeassistant/components/zha/__init__.py:120: note:     Got:
+ homeassistant/components/zha/__init__.py:120: note:         def get_firmware_info(hass: HomeAssistant, config_entry: ConfigEntry[Any]) -> FirmwareInfo | None
+ homeassistant/components/otbr/__init__.py:40: error: Argument 3 to "async_register_firmware_info_provider" has incompatible type Module; expected "SyncHardwareFirmwareInfoModule | AsyncHardwareFirmwareInfoModule"  [arg-type]
+ homeassistant/components/otbr/__init__.py:40: note: Following member(s) of Module "homeassistant.components.otbr.homeassistant_hardware" have conflicts:
+ homeassistant/components/otbr/__init__.py:40: note:     Expected:
+ homeassistant/components/otbr/__init__.py:40: note:         def async_get_firmware_info(hass: HomeAssistant, entry: ConfigEntry[Any]) -> Coroutine[Any, Any, FirmwareInfo | None]
+ homeassistant/components/otbr/__init__.py:40: note:     Got:
+ homeassistant/components/otbr/__init__.py:40: note:         def async_get_firmware_info(hass: HomeAssistant, config_entry: ConfigEntry[OTBRData]) -> Coroutine[Any, Any, FirmwareInfo | None]

nionutils (https://github.com/nion-software/nionutils)
+ nion/utils/StructuredModel.py:91: error: Incompatible return value type (got "RecordModel", expected "ModelLike")  [return-value]
+ nion/utils/StructuredModel.py:91: note: Following member(s) of "RecordModel" have conflicts:
+ nion/utils/StructuredModel.py:91: note:     Expected:
+ nion/utils/StructuredModel.py:91: note:         def copy_from(self, m: Any) -> Any
+ nion/utils/StructuredModel.py:91: note:     Got:
+ nion/utils/StructuredModel.py:91: note:         def copy_from(self, record: RecordModel) -> None
+ nion/utils/StructuredModel.py:91: note:     Expected:
+ nion/utils/StructuredModel.py:91: note:         def from_dict_value(self, value: dict[str, Any] | list[Any] | tuple[Any] | str | int | None) -> None
+ nion/utils/StructuredModel.py:91: note:     Got:
+ nion/utils/StructuredModel.py:91: note:         def from_dict_value(self, values: dict[str, Any] | list[Any] | tuple[Any] | str | int | None) -> None
+ nion/utils/StructuredModel.py:93: error: Incompatible return value type (got "ArrayModel", expected "ModelLike")  [return-value]
+ nion/utils/StructuredModel.py:93: note: Following member(s) of "ArrayModel" have conflicts:
+ nion/utils/StructuredModel.py:93: note:     Expected:
+ nion/utils/StructuredModel.py:93: note:         def copy_from(self, m: Any) -> Any
+ nion/utils/StructuredModel.py:93: note:     Got:
+ nion/utils/StructuredModel.py:93: note:         def copy_from(self, array: ArrayModel) -> None
+ nion/utils/StructuredModel.py:93: note:     Expected:
+ nion/utils/StructuredModel.py:93: note:         def from_dict_value(self, value: dict[str, Any] | list[Any] | tuple[Any] | str | int | None) -> None
+ nion/utils/StructuredModel.py:93: note:     Got:
+ nion/utils/StructuredModel.py:93: note:         def from_dict_value(self, values: dict[str, Any] | list[Any] | tuple[Any] | str | int | None) -> None

build (https://github.com/pypa/build)
+ src/build/util.py:19: error: Argument 1 to "PathDistribution" has incompatible type "Path"; expected "SimplePath"  [arg-type]
+ src/build/util.py:19: note: Following member(s) of "Path" have conflicts:
+ src/build/util.py:19: note:     Expected:
+ src/build/util.py:19: note:         def __truediv__(self, str | PathLike[str], /) -> SimplePath
+ src/build/util.py:19: note:     Got:
+ src/build/util.py:19: note:         def __truediv__(self, str | PathLike[str], /) -> Path
+ src/build/util.py:19: note:     Expected:
+ src/build/util.py:19: note:         def joinpath(self, other: str | PathLike[str]) -> SimplePath
+ src/build/util.py:19: note:     Got:
+ src/build/util.py:19: note:         def joinpath(self, *other: str | PathLike[str]) -> Path
+ src/build/util.py:19: note:     <1 more conflict(s) not shown>

xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_typed_ops.py: note: In function "test_dataset_typed_ops":
+ xarray/tests/test_typed_ops.py:138: error: Argument 1 to "_test" has incompatible type "ndarray[tuple[Any, ...], dtype[Any]]"; expected "Dataset"  [arg-type]

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protocol incorrectly matches when positional or keyword parameter matches *args

3 participants