Skip to content

Be strict about arg names in protocol compatibility#21016

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

Be strict about arg names in protocol compatibility#21016
hauntsaninja wants to merge 2 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
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]

tornado (https://github.com/tornadoweb/tornado)
+ tornado/websocket.py:773: error: Incompatible return value type (got "_Compress", expected "_Compressor")  [return-value]
+ tornado/websocket.py:810: error: Incompatible return value type (got "_Decompress", expected "_Decompressor")  [return-value]

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: error: Argument 1 to "accept" of "Expr" has incompatible type "Resolver"; expected "VisitorProtocol"  [arg-type]
+ pylox/interpreter.py:113: error: Argument 1 to "accept" of "Expr" has incompatible type "Interpreter"; expected "VisitorProtocol"  [arg-type]
+ pylox/interpreter.py:113: error: Argument 1 to "accept" of "Stmt" has incompatible type "Interpreter"; expected "VisitorProtocol"  [arg-type]

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/compilers/mixins/apple.py:27:52: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str]")  [assignment]
+ 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/clike.py:210:20: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ 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:256:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ 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:189:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/dependencies/pkgconfig.py:215:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ 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/cmake/interpreter.py:559:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/cmake/interpreter.py:566:20: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/cmake/interpreter.py:568:20: error: Incompatible return value type (got "list[Never]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/cmake/interpreter.py:568:20: note: Following member(s) of "list[Never]" have conflicts:
+ mesonbuild/cmake/interpreter.py:568:20: note:     Expected:
+ mesonbuild/cmake/interpreter.py:568:20: note:         def count(self, item: str) -> int
+ mesonbuild/cmake/interpreter.py:568:20: note:     Got:
+ mesonbuild/cmake/interpreter.py:568:20: note:         def count(self, Never, /) -> int
+ mesonbuild/cmake/interpreter.py:568:20: note:     Expected:
+ mesonbuild/cmake/interpreter.py:568:20: note:         def index(self, item: str) -> int
+ mesonbuild/cmake/interpreter.py:568:20: note:     Got:
+ mesonbuild/cmake/interpreter.py:568:20: note:         def index(self, Never, SupportsIndex = ..., SupportsIndex = ..., /) -> int
+ mesonbuild/backend/backends.py:1429:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/backend/backends.py:1438:16: error: Incompatible return value type (got "list[str]", expected "ImmutableListProtocol[str]")  [return-value]
+ mesonbuild/modules/external_project.py:123:25: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str]")  [assignment]
+ mesonbuild/modules/external_project.py:133:25: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[str]")  [assignment]
+ mesonbuild/modules/codegen.py:89:79: error: Argument "default_factory" to "field" has incompatible type "type[list[_T]]"; expected "Callable[[], ImmutableListProtocol[str]]"  [arg-type]
+ mesonbuild/dependencies/cuda.py:29:60: error: Incompatible types in assignment (expression has type "list[str]", variable has type "ImmutableListProtocol[Literal['c', 'cpp', 'cuda', 'fortran', 'd', 'objc', 'objcpp', 'rust', 'vala', 'cs', 'swift', 'java', 'cython', 'nasm', 'masm', 'linearasm']]")  [assignment]
+ mesonbuild/dependencies/cuda.py:29:60: note: Following member(s) of "list[str]" have conflicts:
+ mesonbuild/dependencies/cuda.py:29:60: note:     Expected:
+ mesonbuild/dependencies/cuda.py:29:60: note:         def __add__(self, list[Literal['c', 'cpp', 'cuda', 'fortran', 'd', 'objc', 'objcpp', 'rust', 'vala', 'cs', 'swift', 'java', 'cython', 'nasm', 'masm', 'linearasm']], /) -> list[Literal['c', 'cpp', 'cuda', 'fortran', 'd', 'objc', 'objcpp', 'rust', 'vala', 'cs', 'swift', 'java', 'cython', 'nasm', 'masm', 'linearasm']]
+ mesonbuild/dependencies/cuda.py:29:60: note:     Got:
+ mesonbuild/dependencies/cuda.py:29:60: note:         @overload
+ mesonbuild/dependencies/cuda.py:29:60: note:         def __add__(self, list[str], /) -> list[str]
+ mesonbuild/dependencies/cuda.py:29:60: note:         @overload
+ mesonbuild/dependencies/cuda.py:29:60: note:         def [_S] __add__(self, list[_S], /) -> list[_S | str]
+ mesonbuild/dependencies/cuda.py:29:60: note:     Expected:
+ mesonbuild/dependencies/cuda.py:29:60: note:         @overload
+ mesonbuild/dependencies/cuda.py:29:60: note:         def __getitem__(self, int, /) -> Literal['c', 'cpp', 'cuda', 'fortran', 'd', 'objc', 'objcpp', 'rust', 'vala', 'cs', 'swift', 'java', 'cython', 'nasm', 'masm', 'linearasm']
+ mesonbuild/dependencies/cuda.py:29:60: note:         @overload
+ mesonbuild/dependencies/cuda.py:29:60: note:         def __getitem__(self, slice[Any, Any, Any], /) -> list[Literal['c', 'cpp', 'cuda', 'fortran', 'd', 'objc', 'objcpp', 'rust', 'vala', 'cs', 'swift', 'java', 'cython', 'nasm', 'masm', 'linearasm']]
+ mesonbuild/dependencies/cuda.py:29:60: note:     Got:
+ mesonbuild/dependencies/cuda.py:29:60: note:         @overload
+ mesonbuild/dependencies/cuda.py:29:60: note:         def __getitem__(self, SupportsIndex, /) -> str
+ mesonbuild/dependencies/cuda.py:29:60: note:         @overload
+ mesonbuild/dependencies/cuda.py:29:60: note:         def __getitem__(self, slice[SupportsIndex, SupportsIndex, SupportsIndex], /) -> list[str]
+ mesonbuild/dependencies/cuda.py:29:60: note:     <3 more conflict(s) not shown>

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]

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:307: error: Incompatible return value type (got "HttpBasicAuthProvider", expected "AuthProvider[Any]")  [return-value]
+ src/schemathesis/specs/openapi/adapter/security.py:310: error: Incompatible return value type (got "HttpBearerAuthProvider", expected "AuthProvider[Any]")  [return-value]
+ 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: error: Argument "provider" to "SelectiveAuthProvider" has incompatible type "RequestsAuth[Never]"; expected "AuthProvider[Any]"  [arg-type]
+ 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:373: error: Incompatible types in assignment (expression has type "KeyedCachingAuthProvider[Never]", variable has type "AuthProvider[Any]")  [assignment]
+ src/schemathesis/auths.py:380: error: Incompatible types in assignment (expression has type "SelectiveAuthProvider[Never]", variable has type "AuthProvider[Any]")  [assignment]

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/otbr/__init__.py:40: error: Argument 3 to "async_register_firmware_info_provider" has incompatible type Module; expected "SyncHardwareFirmwareInfoModule | AsyncHardwareFirmwareInfoModule"  [arg-type]

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:93: error: Incompatible return value type (got "ArrayModel", expected "ModelLike")  [return-value]

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]

@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.

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