-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fixed a bug that leads to incorrect (unsound) type narrowing when usi… #9868
Merged
Conversation
This file contains 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
…ng the `x in y` type guard pattern. The `in` operator uses equality checks, and `__eq__` can succeed for objects of disjoint types, which means disjointedness cannot be used as the basis for narrowing here. This change also affects the `reportUnnecessaryContains` check, which leverages the same logic. This addresses #9338.
Diff from mypy_primer, showing the effect of this PR on open source code: schemathesis (https://github.com/schemathesis/schemathesis)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:384:70 - error: Argument of type "Unknown | tuple[type, str]" cannot be assigned to parameter "multiple_of" of type "int | float" in function "_negative_multiple_of"
- Type "Unknown | tuple[type, str]" is not assignable to type "int | float"
- Type "tuple[type, str]" is not assignable to type "int | float"
- "tuple[type, str]" is not assignable to "int"
- "tuple[type, str]" is not assignable to "float" (reportArgumentType)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:389:45 - error: Operator "<" not supported for types "Literal[0]" and "Unknown | tuple[type, str]"
- Operator "<" not supported for types "Literal[0]" and "tuple[type, str]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:389:49 - error: Operator "<" not supported for types "Unknown | tuple[type, str]" and "Literal[8192]"
- Operator "<" not supported for types "tuple[type, str]" and "Literal[8192]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:391:51 - error: Operator "-" not supported for types "Unknown | tuple[type, str]" and "Literal[1]"
- Operator "-" not supported for types "tuple[type, str]" and "Literal[1]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:411:45 - error: Operator "<" not supported for types "Unknown | tuple[type, str]" and "Literal[8192]"
- Operator "<" not supported for types "tuple[type, str]" and "Literal[8192]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:413:51 - error: Operator "+" not supported for types "Unknown | tuple[type, str]" and "Literal[1]"
- Operator "+" not supported for types "tuple[type, str]" and "Literal[1]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:439:66 - error: Argument of type "Unknown | tuple[type, str]" cannot be assigned to parameter "required" of type "list[str]" in function "_negative_required"
- Type "Unknown | tuple[type, str]" is not assignable to type "list[str]"
- "tuple[type, str]" is not assignable to "list[str]" (reportArgumentType)
- /tmp/mypy_primer/projects/schemathesis/src/schemathesis/generation/coverage.py:466:64 - error: Argument of type "type | str" cannot be assigned to parameter "schema" of type "dict[Unknown, Unknown] | bool" in function "cover_schema_iter"
- Type "type | str" is not assignable to type "dict[Unknown, Unknown] | bool"
- Type "str" is not assignable to type "dict[Unknown, Unknown] | bool"
- "str" is not assignable to "dict[Unknown, Unknown]"
- "str" is not assignable to "bool" (reportArgumentType)
- 299 errors, 92 warnings, 0 informations
+ 291 errors, 92 warnings, 0 informations
sympy (https://github.com/sympy/sympy)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:97:32 - error: Argument of type "list[Unknown] | list[Unknown | Basic] | Unknown | Permutation | FreeGroupElement" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+ /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:97:32 - error: Argument of type "list[Unknown] | Unknown | Permutation | FreeGroupElement" cannot be assigned to parameter "obj" of type "Sized" in function "len"
- Type "list[Unknown] | list[Unknown | Basic] | Unknown | Permutation | FreeGroupElement" is not assignable to type "Sized"
+ Type "list[Unknown] | Unknown | Permutation | FreeGroupElement" is not assignable to type "Sized"
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:99:22 - error: Cannot access attribute "is_identity" for class "Basic"
- Attribute "is_identity" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:104:42 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[-1]"
- Operator "**" not supported for types "Basic" and "Literal[-1]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:174:40 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[-1]"
- Operator "**" not supported for types "Basic" and "Literal[-1]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/perm_groups.py:1248:25 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[-1]"
- Operator "**" not supported for types "Basic" and "Literal[-1]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/perm_groups.py:4322:27 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[-1]"
- Operator "**" not supported for types "Basic" and "Literal[-1]" (reportOperatorIssue)
- /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_perm_groups.py:860:13 - error: Operator "*" not supported for types "Unknown | Basic" and "Permutation | Unknown | Coset"
- Operator "*" not supported for types "Basic" and "Coset" (reportOperatorIssue)
- /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:355:49 - error: Cannot access attribute "epsilon_eq" for class "NaN*"
+ /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:355:49 - error: Cannot access attribute "epsilon_eq" for class "Expr*"
- Attribute "epsilon_eq" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:355:49 - error: Cannot access attribute "epsilon_eq" for class "Infinity*"
- Attribute "epsilon_eq" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:355:49 - error: Cannot access attribute "epsilon_eq" for class "NegativeInfinity*"
- Attribute "epsilon_eq" is unknown (reportAttributeAccessIssue)
- /tmp/mypy_primer/projects/sympy/sympy/concrete/tests/test_sums_products.py:355:49 - error: Cannot access attribute "epsilon_eq" for class "ComplexInfinity*"
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:481:23 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:484:25 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__delitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:487:13 - error: Argument of type "bytes | Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:487:13 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
- Type "bytes | Basic | Zero | Unknown" is not assignable to type "bytes"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:618:21 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:621:29 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__delitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:625:29 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:632:25 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:635:29 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:637:33 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__delitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:640:34 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:645:33 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:645:33 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:648:33 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:648:33 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:651:33 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:780:32 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__getitem__"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
+ "Basic" is not assignable to "bytes" (reportArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:782:13 - error: Argument of type "bytes | Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
+ /tmp/mypy_primer/projects/sympy/sympy/core/exprtools.py:782:13 - error: Argument of type "Basic | Zero | Unknown" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
- Type "bytes | Basic | Zero | Unknown" is not assignable to type "bytes"
+ Type "Basic | Zero | Unknown" is not assignable to type "bytes"
- /tmp/mypy_primer/projects/sympy/sympy/core/numbers.py:4132:39 - error: Argument of type "NaN | NaN* | Unknown | Basic" cannot be assigned to parameter "e" of type "Expr | complex" in function "__new__"
+ /tmp/mypy_primer/projects/sympy/sympy/core/numbers.py:4132:39 - error: Argument of type "NaN | Unknown | Basic" cannot be assigned to parameter "e" of type "Expr | complex" in function "__new__"
- Type "NaN | NaN* | Unknown | Basic" is not assignable to type "Expr | complex"
+ Type "NaN | Unknown | Basic" is not assignable to type "Expr | complex"
... (truncated 67 lines) ...
pyodide (https://github.com/pyodide/pyodide)
- /tmp/mypy_primer/projects/pyodide/src/tests/test_pyproxy.py:393:42 - error: No overloads for "cast" match the provided arguments (reportCallIssue)
- /tmp/mypy_primer/projects/pyodide/src/tests/test_pyproxy.py:393:50 - error: Argument of type "str" cannot be assigned to parameter "format" of type "_IntegerFormats" in function "cast"
- Type "str" is not assignable to type "_IntegerFormats"
- "str" is not assignable to type "Literal['b']"
- "str" is not assignable to type "Literal['B']"
- "str" is not assignable to type "Literal['@b']"
- "str" is not assignable to type "Literal['@B']"
- "str" is not assignable to type "Literal['h']"
- "str" is not assignable to type "Literal['H']"
- "str" is not assignable to type "Literal['@h']"
- ... (reportArgumentType)
- 756 errors, 14 warnings, 0 informations
+ 754 errors, 14 warnings, 0 informations
bokeh (https://github.com/bokeh/bokeh)
+ /tmp/mypy_primer/projects/bokeh/tests/unit/bokeh/colors/test_groups.py:209:22 - error: Argument of type "ColorGroup" cannot be assigned to parameter "name" of type "str" in function "getattr"
+ "ColorGroup" is not assignable to "str" (reportArgumentType)
+ /tmp/mypy_primer/projects/bokeh/tests/unit/bokeh/colors/test_groups.py:210:25 - error: Operator "+" not supported for types "Literal['_']" and "ColorGroup" (reportOperatorIssue)
+ /tmp/mypy_primer/projects/bokeh/tests/unit/bokeh/colors/test_groups.py:211:26 - error: Argument of type "Any | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+ Type "Any | None" is not assignable to type "Sized"
+ "None" is incompatible with protocol "Sized"
+ "__len__" is not present (reportArgumentType)
+ /tmp/mypy_primer/projects/bokeh/tests/unit/bokeh/colors/test_groups.py:212:14 - error: Object of type "None" cannot be used as iterable value (reportOptionalIterable)
- 6250 errors, 294 warnings, 0 informations
+ 6254 errors, 294 warnings, 0 informations
openlibrary (https://github.com/internetarchive/openlibrary)
- Return type mismatch: base method returns type "Iterator[tuple[str, str | MarcFieldBase]]", override returns type "Generator[tuple[str, MockField], Any, None]"
+ Return type mismatch: base method returns type "Iterator[tuple[str, str | MarcFieldBase]]", override returns type "Generator[tuple[Unknown, MockField], Any, None]"
- "Generator[tuple[str, MockField], Any, None]" is not assignable to "Iterator[tuple[str, str | MarcFieldBase]]"
+ "Generator[tuple[Unknown, MockField], Any, None]" is not assignable to "Iterator[tuple[str, str | MarcFieldBase]]"
- Type parameter "_T_co@Iterator" is covariant, but "tuple[str, MockField]" is not a subtype of "tuple[str, str | MarcFieldBase]"
+ Type parameter "_T_co@Iterator" is covariant, but "tuple[Unknown, MockField]" is not a subtype of "tuple[str, str | MarcFieldBase]"
- "tuple[str, MockField]" is not assignable to "tuple[str, str | MarcFieldBase]"
+ "tuple[Unknown, MockField]" is not assignable to "tuple[str, str | MarcFieldBase]"
- /tmp/mypy_primer/projects/openlibrary/openlibrary/plugins/openlibrary/api.py:66:45 - error: Argument of type "str" cannot be assigned to parameter "id_type" of type "Literal['identifier', 'openlibrary_work', 'openlibrary_edition']" in function "get_availability"
- Type "str" is not assignable to type "Literal['identifier', 'openlibrary_work', 'openlibrary_edition']"
- "str" is not assignable to type "Literal['identifier']"
- "str" is not assignable to type "Literal['openlibrary_work']"
- "str" is not assignable to type "Literal['openlibrary_edition']" (reportArgumentType)
- 1252 errors, 68 warnings, 0 informations
+ 1251 errors, 68 warnings, 0 informations
steam.py (https://github.com/Gobot1234/steam.py)
+ /tmp/mypy_primer/projects/steam.py/steam/ext/csgo/state.py:210:21 - error: Argument of type "int" cannot be assigned to parameter "key" of type "AssetID" in function "__delitem__"
+ "int" is not assignable to "AssetID" (reportArgumentType)
+ /tmp/mypy_primer/projects/steam.py/steam/ext/csgo/state.py:211:21 - error: Argument of type "int" cannot be assigned to parameter "key" of type "AssetID" in function "__delitem__"
+ "int" is not assignable to "AssetID" (reportArgumentType)
- 8517 errors, 94 warnings, 0 informations
+ 8519 errors, 94 warnings, 0 informations
prefect (https://github.com/PrefectHQ/prefect)
+ /tmp/mypy_primer/projects/prefect/src/prefect/server/api/server.py:576:16 - error: Argument of type "tuple[str, bool, bool]" cannot be assigned to parameter "key" of type "tuple[Settings, bool]" in function "__getitem__"
+ "tuple[str, bool, bool]" is not assignable to "tuple[Settings, bool]"
+ Tuple size mismatch; expected 2 but received 3 (reportArgumentType)
- 5540 errors, 284 warnings, 0 informations
+ 5541 errors, 284 warnings, 0 informations
core (https://github.com/home-assistant/core)
- /tmp/mypy_primer/projects/core/homeassistant/components/directv/media_player.py:161:20 - error: Type "str" is not assignable to return type "MediaType | None"
- Type "str" is not assignable to type "MediaType | None"
- "str" is not assignable to "MediaType"
- "str" is not assignable to "None" (reportReturnType)
+ "Literal['assist_satellite']" is not assignable to "Platform" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/esphome/manager.py:488:53 - error: Argument of type "Literal['assist_satellite']" cannot be assigned to parameter "element" of type "Platform" in function "remove"
+ /tmp/mypy_primer/projects/core/homeassistant/components/group/sensor.py:660:42 - error: Argument of type "dict[str, str | (() -> (SensorDeviceClass | None))]" cannot be assigned to parameter "translation_placeholders" of type "dict[str, str] | None" in function "async_create_issue"
+ Type "dict[str, str | (() -> (SensorDeviceClass | None))]" is not assignable to type "dict[str, str] | None"
+ "dict[str, str | (() -> (SensorDeviceClass | None))]" is not assignable to "dict[str, str]"
+ Type parameter "_VT@dict" is invariant, but "str | (() -> (SensorDeviceClass | None))" is not the same as "str"
+ Consider switching from "dict" to "Mapping" which is covariant in the value type
+ "dict[str, str | (() -> (SensorDeviceClass | None))]" is not assignable to "None" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/light/__init__.py:119:28 - error: Argument of type "Literal['onoff']" cannot be assigned to parameter "element" of type "ColorMode" in function "remove"
+ "Literal['onoff']" is not assignable to "ColorMode" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/light/__init__.py:121:28 - error: Argument of type "Literal['brightness']" cannot be assigned to parameter "element" of type "ColorMode" in function "remove"
+ "Literal['brightness']" is not assignable to "ColorMode" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/logbook/processor.py:257:38 - error: Argument of type "EventType[Any] | str | Unknown | None" cannot be assigned to parameter "key" of type "EventType[Any] | str" in function "__getitem__"
+ Type "EventType[Any] | str | Unknown | None" is not assignable to type "EventType[Any] | str"
+ Type "None" is not assignable to type "EventType[Any] | str"
+ "None" is not assignable to "EventType[Any]"
+ "None" is not assignable to "str" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/logbook/processor.py:365:34 - error: Argument of type "Unknown | EventType[Any] | str | None" cannot be assigned to parameter "key" of type "EventType[Any] | str" in function "__getitem__"
+ Type "Unknown | EventType[Any] | str | None" is not assignable to type "EventType[Any] | str"
+ Type "None" is not assignable to type "EventType[Any] | str"
+ "None" is not assignable to "EventType[Any]"
+ "None" is not assignable to "str" (reportArgumentType)
+ "Literal['off']" is not assignable to "HVACMode" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/modbus/climate.py:263:46 - error: Argument of type "Literal['off']" cannot be assigned to parameter "object" of type "HVACMode" in function "append"
+ /tmp/mypy_primer/projects/core/homeassistant/components/sensor/__init__.py:625:27 - error: Argument of type "() -> (SensorStateClass | str | None)" cannot be assigned to parameter "state_class" of type "SensorStateClass | str | None" in function "_numeric_state_expected"
+ Type "() -> (SensorStateClass | str | None)" is not assignable to type "SensorStateClass | str | None"
+ "function" is not assignable to "SensorStateClass"
+ "function" is not assignable to "str"
+ "function" is not assignable to "None" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/sensor/websocket_api.py:44:13 - error: Argument of type "Any | None" cannot be assigned to parameter "key" of type "SensorDeviceClass" in function "__getitem__"
+ Type "Any | None" is not assignable to type "SensorDeviceClass"
+ "None" is not assignable to "SensorDeviceClass" (reportArgumentType)
- /tmp/mypy_primer/projects/core/homeassistant/components/tts/__init__.py:623:17 - error: Argument of type "Unknown | str" cannot be assigned to parameter "key" of type "bytes" in function "__setitem__"
- Type "Unknown | str" is not assignable to type "bytes"
- "str" is not assignable to "bytes" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/wemo/__init__.py:206:23 - error: Argument of type "str" cannot be assigned to parameter "key" of type "Platform" in function "__getitem__"
+ "str" is not assignable to "Platform" (reportArgumentType)
+ /tmp/mypy_primer/projects/core/homeassistant/components/wemo/__init__.py:208:17 - error: Argument of type "str" cannot be assigned to parameter "key" of type "Platform" in function "__getitem__"
+ "str" is not assignable to "Platform" (reportArgumentType)
- 65382 errors, 293 warnings, 0 informations
+ 65391 errors, 293 warnings, 0 informations
antidote (https://github.com/Finistere/antidote)
+ /tmp/mypy_primer/projects/antidote/src/antidote/core/_inject.py:51:9 - error: Expression will always evaluate to True since the types "object" and "type" have no overlap (reportUnnecessaryContains)
- 743 errors, 77 warnings, 0 informations
+ 744 errors, 77 warnings, 0 informations
zulip (https://github.com/zulip/zulip)
- /tmp/mypy_primer/projects/zulip/zerver/actions/message_send.py:1080:35 - error: Type "dict[str, int | list[str] | None]" is not assignable to declared type "UserData"
+ /tmp/mypy_primer/projects/zulip/zerver/actions/message_send.py:1080:35 - error: Type "dict[str, Unknown | int]" is not assignable to declared type "UserData"
- "dict[str, int | list[str] | None]" is not assignable to "UserData" (reportAssignmentType)
+ "dict[str, Unknown | int]" is not assignable to "UserData" (reportAssignmentType)
- /tmp/mypy_primer/projects/zulip/zerver/data_import/rocketchat.py:590:81 - error: Argument of type "str" cannot be assigned to parameter "name_id" of type "int" in function "truncate_name"
- "str" is not assignable to "int" (reportArgumentType)
- 4979 errors, 464 warnings, 0 informations
+ 4978 errors, 464 warnings, 0 informations
xarray (https://github.com/pydata/xarray)
- /tmp/mypy_primer/projects/xarray/xarray/coding/cftime_offsets.py:796:12 - error: Argument of type "str | Unknown | BaseCFTimeOffset | timedelta" cannot be assigned to parameter "key" of type "str" in function "__getitem__"
+ /tmp/mypy_primer/projects/xarray/xarray/coding/cftime_offsets.py:796:12 - error: Argument of type "Unknown | BaseCFTimeOffset | str | timedelta" cannot be assigned to parameter "key" of type "str" in function "__getitem__"
- Type "str | Unknown | BaseCFTimeOffset | timedelta" is not assignable to type "str"
+ Type "Unknown | BaseCFTimeOffset | str | timedelta" is not assignable to type "str"
- /tmp/mypy_primer/projects/xarray/xarray/core/dataset.py:9315:37 - error: Argument of type "T_DatasetPadConstantValues | Any | dict[_Dim, Any] | Literal[0] | None" cannot be assigned to parameter "constant_values" of type "T_VarPadConstantValues | None" in function "pad"
+ /tmp/mypy_primer/projects/xarray/xarray/core/dataset.py:9315:37 - error: Argument of type "T_DatasetPadConstantValues | Any | dict[Any, Any] | Literal[0] | None" cannot be assigned to parameter "constant_values" of type "T_VarPadConstantValues | None" in function "pad"
- Type "T_DatasetPadConstantValues | Any | dict[_Dim, Any] | Literal[0] | None" is not assignable to type "T_VarPadConstantValues | None"
+ Type "T_DatasetPadConstantValues | Any | dict[Any, Any] | Literal[0] | None" is not assignable to type "T_VarPadConstantValues | None"
trio (https://github.com/python-trio/trio)
- /tmp/mypy_primer/projects/trio/src/trio/_tests/check_type_completeness.py:164:37 - error: Argument of type "Any | str | object" cannot be assigned to parameter "element" of type "str" in function "add"
- Type "Any | str | object" is not assignable to type "str"
- "object" is not assignable to "str" (reportArgumentType)
- 4046 errors, 55 warnings, 0 informations
+ 4045 errors, 55 warnings, 0 informations
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- /tmp/mypy_primer/projects/dd-trace-py/ddtrace/contrib/internal/botocore/patch.py:198:46 - error: Argument of type "Any | str | None" cannot be assigned to parameter "key" of type "str" in function "get"
+ /tmp/mypy_primer/projects/dd-trace-py/ddtrace/contrib/internal/botocore/patch.py:198:46 - error: Argument of type "Any | Literal['bedrock-runtime'] | None" cannot be assigned to parameter "key" of type "str" in function "get"
- Type "Any | str | None" is not assignable to type "str"
+ Type "Any | Literal['bedrock-runtime'] | None" is not assignable to type "str"
+ /tmp/mypy_primer/projects/dd-trace-py/tests/profiling/exporter/test_pprof.py:741:34 - error: Argument of type "Package" cannot be assigned to parameter "value" of type "dict[str, str]" in function "remove"
+ "Package" is not assignable to "dict[str, str]" (reportArgumentType)
- 12522 errors, 620 warnings, 0 informations
+ 12523 errors, 620 warnings, 0 informations
mitmproxy (https://github.com/mitmproxy/mitmproxy)
- /tmp/mypy_primer/projects/mitmproxy/mitmproxy/proxy/events.py:97:9 - error: Argument of type "Command | Any | type[Unknown] | type[Command]" cannot be assigned to parameter "key" of type "Command" in function "__setitem__"
+ /tmp/mypy_primer/projects/mitmproxy/mitmproxy/proxy/events.py:97:9 - error: Argument of type "Any | type[Unknown] | type[Command]" cannot be assigned to parameter "key" of type "Command" in function "__setitem__"
- Type "Command | Any | type[Unknown] | type[Command]" is not assignable to type "Command"
+ Type "Any | type[Unknown] | type[Command]" is not assignable to type "Command"
spack (https://github.com/spack/spack)
- /tmp/mypy_primer/projects/spack/lib/spack/spack/cmd/view.py:208:19 - error: Argument of type "str" cannot be assigned to parameter "link_type" of type "LinkType" in function "__init__"
- Type "str" is not assignable to type "LinkType"
- "str" is not assignable to type "Literal['hardlink']"
- "str" is not assignable to type "Literal['hard']"
- "str" is not assignable to type "Literal['copy']"
- "str" is not assignable to type "Literal['relocate']"
- "str" is not assignable to type "Literal['add']"
- "str" is not assignable to type "Literal['symlink']"
- "str" is not assignable to type "Literal['soft']" (reportArgumentType)
- /tmp/mypy_primer/projects/spack/lib/spack/spack/test/cmd/dev_build.py:40:28 - error: Argument of type "Prefix | None" cannot be assigned to parameter "a" of type "StrPath" in function "join"
+ /tmp/mypy_primer/projects/spack/lib/spack/spack/test/cmd/dev_build.py:40:28 - error: Argument of type "Prefix | None" cannot be assigned to parameter "a" of type "BytesPath" in function "join"
- Type "Prefix | None" is not assignable to type "StrPath"
+ Type "Prefix | None" is not assignable to type "BytesPath"
- Type "None" is not assignable to type "StrPath"
+ Type "Prefix" is not assignable to type "BytesPath"
- "None" is not assignable to "str"
+ "Prefix" is not assignable to "bytes"
- "None" is incompatible with protocol "PathLike[str]"
+ "Prefix" is incompatible with protocol "PathLike[bytes]"
... (truncated 106 lines) ...``` |
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.
…ng the
x in y
type guard pattern. Thein
operator uses equality checks, and__eq__
can succeed for objects of disjoint types, which means disjointedness cannot be used as the basis for narrowing here. This change also affects thereportUnnecessaryContains
check, which leverages the same logic. This addresses #9338.