fix(narrowing): propagate walrus narrowing from inside and expressions (closes #19430)#21147
Open
traveltamers wants to merge 4 commits intopython:masterfrom
Open
Conversation
Add _collect_walrus_type_map to TypeChecker that recursively walks arbitrary expression trees collecting AssignmentExpr type narrowings. Call it in find_isinstance_check_helper's "and" branch to register walrus assignments from the right operand into the true-branch type map.
…erand Add regression tests for walrus operator behavior in nested expressions.
for more information, see https://pre-commit.ci
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/types/datetime.py:665: error: Incompatible return value type (got "bytes | None", expected "bytes") [return-value]
+ psycopg/psycopg/types/datetime.py:672: error: Incompatible return value type (got "bytes | None", expected "bytes") [return-value]
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/_internal/concurrency/inspection.py:93: error: Argument 1 to "call_stack" has incompatible type "FrameType | None"; expected "FrameType" [arg-type]
+ src/prefect/results.py:661: error: "None" not callable [misc]
+ src/prefect/results.py:663: error: "None" not callable [misc]
+ src/prefect/server/orchestration/core_policy.py:914: error: Item "None" of "ResourceLease[ConcurrencyLimitLeaseMetadata] | None" has no attribute "resource_ids" [union-attr]
+ src/prefect/server/orchestration/core_policy.py:915: error: Item "None" of "ResourceLease[ConcurrencyLimitLeaseMetadata] | None" has no attribute "metadata" [union-attr]
+ src/prefect/server/orchestration/core_policy.py:918: error: Item "None" of "ResourceLease[ConcurrencyLimitLeaseMetadata] | None" has no attribute "id" [union-attr]
+ src/prefect/workers/base.py:234: error: Unsupported left operand type for | ("None") [operator]
+ src/prefect/workers/base.py:234: note: Both left and right operands are unions
pydantic (https://github.com/pydantic/pydantic)
+ pydantic/json_schema.py:1128: error: Argument 1 to "generate_inner" of "GenerateJsonSchema" has incompatible type "Mapping[str, Any] | None"; expected "Mapping[str, Any] | ModelField | DataclassField | TypedDictField | ComputedField" [arg-type]
+ pydantic/json_schema.py:1153: error: Argument 1 to "generate_inner" of "GenerateJsonSchema" has incompatible type "Mapping[str, Any] | None"; expected "Mapping[str, Any] | ModelField | DataclassField | TypedDictField | ComputedField" [arg-type]
+ pydantic/json_schema.py:1169: error: Argument 1 to "generate_inner" of "GenerateJsonSchema" has incompatible type "Mapping[str, Any] | None"; expected "Mapping[str, Any] | ModelField | DataclassField | TypedDictField | ComputedField" [arg-type]
mkosi (https://github.com/systemd/mkosi)
+ mkosi/installer/__init__.py:83:37: error: List item 1 has incompatible type "str | None"; expected "Path | str" [list-item]
+ mkosi/installer/__init__.py:83:45: error: List item 2 has incompatible type "str | None"; expected "Path | str" [list-item]
+ mkosi/qemu.py:1214:36: error: List item 1 has incompatible type "Path | None"; expected "Path | str" [list-item]
+ mkosi/vmspawn.py:159:41: error: List item 1 has incompatible type "Path | None"; expected "Path | str" [list-item]
+ mkosi/__init__.py:2046:23: error: Incompatible types in assignment (expression has type "list[str | None]", variable has type "list[str]") [assignment]
+ mkosi/__init__.py:3830:77: error: Item "None" of "str | None" has no attribute "partition" [union-attr]
+ mkosi/distribution/fedora.py:90:23: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr]
colour (https://github.com/colour-science/colour)
+ colour/utilities/array.py:1295: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/connector.py:754:13: error: Item "None" of "set[ResponseHandler] | None" has no attribute "discard" [union-attr]
+ aiohttp/connector.py:754:13: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
+ aiohttp/client_ws.py:205:46: error: Argument 1 to "_handle_ping_pong_exception" of "ClientWebSocketResponse" has incompatible type "BaseException | None"; expected "BaseException" [arg-type]
+ aiohttp/web_ws.py:229:46: error: Argument 1 to "_handle_ping_pong_exception" of "WebSocketResponse" has incompatible type "BaseException | None"; expected "BaseException" [arg-type]
anyio (https://github.com/agronholm/anyio)
+ src/anyio/_backends/_asyncio.py:897: error: Value of type "Any | None" is not indexable [index]
mypy (https://github.com/python/mypy)
+ mypy/type_visitor.py:299: error: Incompatible return value type (got "Type | None", expected "Type") [return-value]
+ mypy/expandtype.py:574: error: Incompatible return value type (got "Type | None", expected "Type") [return-value]
+ mypy/config_parser.py:712: error: Unsupported left operand type for + ("object") [operator]
+ mypy/config_parser.py:712: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-operator for more info
+ mypy/config_parser.py:718: error: Unsupported left operand type for + ("object") [operator]
+ mypy/join.py:599: error: "Type" has no attribute "type" [attr-defined]
+ mypy/join.py:601: error: Statement is unreachable [unreachable]
+ mypy/join.py:601: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-unreachable for more info
+ mypy/plugins/enums.py:95: error: Returning Any from function declared to return "Type | None" [no-any-return]
+ mypy/plugins/enums.py:95: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-no-any-return for more info
+ mypy/plugins/enums.py:95: error: Item "SymbolNode" of "SymbolNode | None" has no attribute "type" [union-attr]
+ mypy/plugins/enums.py:95: error: Item "None" of "SymbolNode | None" has no attribute "type" [union-attr]
+ mypy/plugins/enums.py:95: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
+ mypy/semanal.py:1408: error: Returning Any from function declared to return "str | None" [no-any-return]
+ mypy/semanal.py:1408: error: "Expression" has no attribute "value" [attr-defined]
+ mypy/checker.py:3856: error: Item "None" of "TypeInfo | None" has no attribute "is_named_tuple" [union-attr]
+ mypy/plugins/default.py:307: error: "ProperType" has no attribute "copy_modified" [attr-defined]
+ mypy/stubgen.py:866: error: Item "None" of "DataclassTransformSpec | None" has no attribute "field_specifiers" [union-attr]
+ mypy/suggestions.py:667: error: Item "ProperType" of "ProperType | None" has no attribute "ret_type" [union-attr]
+ mypy/suggestions.py:667: error: Item "None" of "ProperType | None" has no attribute "ret_type" [union-attr]
+ mypyc/irbuild/for_helpers.py:1304: error: "Expression" has no attribute "fullname" [attr-defined]
altair (https://github.com/vega/altair)
+ tools/codemod.py:57: error: Argument 1 to "Path" has incompatible type "str | None"; expected "str | PathLike[str]" [arg-type]
+ altair/datasets/_readimpl.py:265: error: Item "None" of "str | None" has no attribute "split" [union-attr]
+ tools/update_init_file.py:167: error: Incompatible types in assignment (expression has type "str | None", variable has type "str | Path") [assignment]
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/dependencies/callbacks.py:75: error: Incompatible return value type (got "OwnUser | None", expected "OwnUser") [return-value]
+ tanjun/conversion.py:344: error: Value of type variable "_PartialChannelT" of "_assert_type" of "ToChannel" cannot be "PermissibleGuildChannel | None" [type-var]
+ tanjun/conversion.py:344: error: Incompatible return value type (got "PermissibleGuildChannel | None", expected "PartialChannel") [return-value]
+ tanjun/conversion.py:437: error: Incompatible return value type (got "KnownCustomEmoji | None", expected "KnownCustomEmoji") [return-value]
+ tanjun/conversion.py:494: error: Incompatible return value type (got "GatewayGuild | None", expected "Guild") [return-value]
+ tanjun/conversion.py:546: error: Incompatible return value type (got "InviteWithMetadata | None", expected "Invite") [return-value]
+ tanjun/conversion.py:607: error: Incompatible return value type (got "InviteWithMetadata | None", expected "InviteWithMetadata") [return-value]
+ tanjun/conversion.py:671: error: Incompatible return value type (got "Member | None", expected "Member") [return-value]
+ tanjun/conversion.py:744: error: Incompatible return value type (got "MemberPresence | None", expected "MemberPresence") [return-value]
+ tanjun/conversion.py:787: error: Incompatible return value type (got "Role | None", expected "Role") [return-value]
+ tanjun/conversion.py:843: error: Incompatible return value type (got "User | None", expected "User") [return-value]
+ tanjun/conversion.py:905: error: Incompatible return value type (got "Message | None", expected "Message") [return-value]
+ tanjun/conversion.py:973: error: Incompatible return value type (got "VoiceState | None", expected "VoiceState") [return-value]
+ tanjun/_internal/cache.py:74: error: Incompatible return value type (got "PermissibleGuildChannel | None", expected "PermissibleGuildChannel") [return-value]
+ tanjun/_internal/cache.py:82: error: Incompatible return value type (got "PermissibleGuildChannel | None", expected "PermissibleGuildChannel") [return-value]
+ tanjun/_internal/cache.py:100: error: Incompatible return value type (got "PermissibleGuildChannel | None", expected "PermissibleGuildChannel") [return-value]
+ tanjun/parsing.py:588: error: Argument 2 to "convert" of "Parameter" has incompatible type "str | None"; expected "str" [arg-type]
+ tanjun/dependencies/locales.py:123: error: Item "None" of "Match[str] | None" has no attribute "groups" [union-attr]
+ tanjun/dependencies/locales.py:140: error: Item "None" of "str | None" has no attribute "format" [union-attr]
+ tanjun/dependencies/locales.py:143: error: Item "None" of "str | None" has no attribute "format" [union-attr]
+ tanjun/checks.py:532: error: Argument 2 to "fetch_permissions" has incompatible type "Member | None"; expected "Member" [arg-type]
+ tanjun/clients.py:1540: error: Item "None" of "AppCommand[Any] | None" has no attribute "set_tracked_command" [union-attr]
+ tanjun/clients.py:2379: error: Item "None" of "SingleStoreCache[OwnUser] | None" has no attribute "get" [union-attr]
+ tanjun/clients.py:2400: error: Argument 1 to "subscribe" of "EventManager" has incompatible type "type[MessageCreateEvent] | None"; expected "type[Any]" [arg-type]
core (https://github.com/home-assistant/core)
+ homeassistant/helpers/translation.py:82: error: Value expression in dictionary comprehension has incompatible type "dict[str, Any] | str | None"; expected type "dict[str, Any] | str" [misc]
+ homeassistant/helpers/translation.py:127: error: Item "None" of "Integration | None" has no attribute "name" [union-attr]
+ homeassistant/helpers/entity_registry.py:298: error: Item "None" of "ReadOnlyDict[str, Any] | None" has no attribute "get" [union-attr]
+ homeassistant/helpers/entity_registry.py:299: error: Item "None" of "ReadOnlyDict[str, Any] | None" has no attribute "get" [union-attr]
+ homeassistant/helpers/template/helpers.py:65: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/helpers/template/__init__.py:921: error: Unused "type: ignore" comment [unused-ignore]
+ homeassistant/helpers/template/__init__.py:921: error: Item "None" of "RenderInfo | None" has no attribute "entities" [union-attr]
+ homeassistant/helpers/template/__init__.py:921: note: Error code "union-attr" not covered by "type: ignore" comment
+ homeassistant/helpers/template/__init__.py:921: error: Item "AbstractSet[str]" of "AbstractSet[str] | Any" has no attribute "add" [union-attr]
+ homeassistant/helpers/template/__init__.py:930: error: Unused "type: ignore" comment [unused-ignore]
+ homeassistant/helpers/template/__init__.py:930: error: Item "None" of "RenderInfo | None" has no attribute "entities" [union-attr]
+ homeassistant/helpers/template/__init__.py:930: note: Error code "union-attr" not covered by "type: ignore" comment
+ homeassistant/helpers/template/__init__.py:930: error: Item "AbstractSet[str]" of "AbstractSet[str] | Any" has no attribute "add" [union-attr]
+ homeassistant/helpers/entity.py:728: error: Argument 1 to "_substitute_name_placeholders" of "Entity" has incompatible type "str | None"; expected "str" [arg-type]
+ homeassistant/config_entries.py:588: error: Item "None" of "type[ConfigFlow] | None" has no attribute "async_supports_options_flow" [union-attr]
+ homeassistant/config_entries.py:613: error: Item "None" of "type[ConfigFlow] | None" has no attribute "async_get_supported_subentry_types" [union-attr]
+ homeassistant/config_entries.py:1576: error: Item "None" of "Future[None] | None" has no attribute "set_result" [union-attr]
+ homeassistant/config_entries.py:1632: error: Item "None" of "ConfigEntry[Any] | None" has no attribute "discovery_keys" [union-attr]
+ homeassistant/config_entries.py:1641: error: Item "None" of "ConfigEntry[Any] | None" has no attribute "domain" [union-attr]
+ homeassistant/config_entries.py:1643: error: Item "None" of "ConfigEntry[Any] | None" has no attribute "discovery_keys" [union-attr]
+ homeassistant/config_entries.py:1647: error: Argument 1 to "async_update_entry" of "ConfigEntries" has incompatible type "ConfigEntry[Any] | None"; expected "ConfigEntry[Any]" [arg-type]
+ homeassistant/config_entries.py:4066: error: Incompatible return value type (got "type[ConfigFlow] | None", expected "type[ConfigFlow]") [return-value]
+ homeassistant/helpers/integration_platform.py:137: error: List comprehension has incompatible type List[Future[Awaitable[None] | None] | None]; expected List[Future[Awaitable[None] | None]] [misc]
+ homeassistant/components/websocket_api/auth.py:104: error: Item "None" of "RefreshToken | None" has no attribute "user" [union-attr]
+ homeassistant/components/websocket_api/auth.py:109: error: Item "None" of "RefreshToken | None" has no attribute "id" [union-attr]
+ homeassistant/helpers/schema_config_entry_flow.py:193: error: Item "None" of "Schema | None" has no attribute "schema" [union-attr]
+ homeassistant/components/zeroconf/discovery.py:365: error: Argument 1 to "_async_check_instance_id_conflict" of "ZeroconfDiscovery" has incompatible type "str | None"; expected "str" [arg-type]
+ homeassistant/components/zeroconf/discovery.py:380: error: Item "None" of "HomeKitDiscoveredIntegration | None" has no attribute "domain" [union-attr]
+ homeassistant/components/zeroconf/discovery.py:383: error: Item "None" of "HomeKitDiscoveredIntegration | None" has no attribute "domain" [union-attr]
+ homeassistant/components/zeroconf/discovery.py:395: error: Item "None" of "HomeKitDiscoveredIntegration | None" has no attribute "always_discover" [union-attr]
+ homeassistant/components/hassio/coordinator.py:454: error: Item "None" of "DeviceEntry | None" has no attribute "id" [union-attr]
+ homeassistant/components/lock/__init__.py:302: error: Argument 1 to "match" of "Pattern" has incompatible type "Any | None"; expected "str" [arg-type]
+ homeassistant/components/lock/__init__.py:304: error: Incompatible types in assignment (expression has type "Any | None", variable has type "str") [assignment]
+ homeassistant/components/light/__init__.py:899: error: Value of type "tuple[float, float] | None" is not indexable [index]
+ homeassistant/components/light/__init__.py:900: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:901: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:903: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:904: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:905: error: Value of type "tuple[float, float] | None" is not indexable [index]
+ homeassistant/components/light/__init__.py:907: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:908: error: Value of type "tuple[int, int, int] | None" is not indexable [index]
+ homeassistant/components/light/__init__.py:909: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:913: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:916: error: Value of type "tuple[int, int, int, int] | None" is not indexable [index]
+ homeassistant/components/light/__init__.py:919: error: Too many arguments for "color_rgbww_to_rgb" [call-arg]
+ homeassistant/components/light/__init__.py:919: error: Expected iterable as variadic argument [misc]
+ homeassistant/components/light/__init__.py:924: error: Value of type "tuple[int, int, int, int, int] | None" is not indexable [index]
+ homeassistant/components/light/__init__.py:929: error: Argument 1 to "color_temperature_to_hs" has incompatible type "int | None"; expected "float" [arg-type]
+ homeassistant/components/event/__init__.py:198: error: Item "None" of "EventExtraStoredData | None" has no attribute "last_event_type" [union-attr]
+ homeassistant/components/event/__init__.py:199: error: Item "None" of "EventExtraStoredData | None" has no attribute "last_event_attributes" [union-attr]
+ homeassistant/components/sensor/__init__.py:406: error: Item "None" of "type[BaseUnitConverter] | None" has no attribute "UNIT_CLASS" [union-attr]
+ homeassistant/components/sensor/__init__.py:533: error: Argument 1 to "_is_valid_suggested_unit" of "SensorEntity" has incompatible type "str | None"; expected "str" [arg-type]
+ homeassistant/components/sensor/__init__.py:714: error: Item "None" of "type[BaseUnitConverter] | None" has no attribute "converter_factory" [union-attr]
+ homeassistant/components/stream/hls.py:393: error: Item "None" of "Segment | None" has no attribute "parts" [union-attr]
+ homeassistant/components/stream/hls.py:395: error: Item "None" of "Segment | None" has no attribute "parts" [union-attr]
+ homeassistant/components/stream/hls.py:398: error: Item "None" of "Segment | None" has no attribute "parts" [union-attr]
+ homeassistant/components/stream/hls.py:435: error: Item "None" of "Segment | None" has no attribute "get_data" [union-attr]
+ homeassistant/components/intent/timers.py:296: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/intent/timers.py:298: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/intent/timers.py:299: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/intent/timers.py:301: error: Item "None" of "AreaEntry | None" has no attribute "name" [union-attr]
+ homeassistant/components/intent/timers.py:302: error: Item "None" of "AreaEntry | None" has no attribute "floor_id" [union-attr]
+ homeassistant/components/intent/timers.py:628: error: Item "None" of "AreaEntry | None" has no attribute "id" [union-attr]
+ homeassistant/components/intent/timers.py:636: error: Item "None" of "AreaEntry | None" has no attribute "floor_id" [union-attr]
+ homeassistant/components/group/event.py:148: error: Item "None" of "State | None" has no attribute "attributes" [union-attr]
+ homeassistant/components/group/event.py:158: error: Argument 1 to "_trigger_event" of "EventEntity" has incompatible type "Any | None"; expected "str" [arg-type]
+ homeassistant/components/intent/__init__.py:560: error: Item "None" of "AreaEntry | None" has no attribute "temperature_entity_id" [union-attr]
+ homeassistant/components/script/__init__.py:769: error: Argument 1 to "parse_datetime" has incompatible type "Any | None"; expected "str" [arg-type]
+ homeassistant/helpers/llm.py:297: error: Item "None" of "AreaEntry | None" has no attribute "floor_id" [union-attr]
+ homeassistant/helpers/llm.py:299: error: Item "None" of "AreaEntry | None" has no attribute "floor_id" [union-attr]
+ homeassistant/helpers/llm.py:513: error: Item "None" of "AreaEntry | None" has no attribute "floor_id" [union-attr]
+ homeassistant/helpers/llm.py:514: error: Item "None" of "AreaEntry | None" has no attribute "floor_id" [union-attr]
+ homeassistant/components/tts/__init__.py:920: error: Value of type variable "AnyOrLiteralStr" of "splitext" cannot be "str | None" [type-var]
+ homeassistant/components/tts/__init__.py:920: error: Value of type "str | None" is not indexable [index]
+ homeassistant/components/conversation/chat_log.py:720: error: Item "None" of "User | None" has no attribute "name" [union-attr]
+ homeassistant/components/assist_pipeline/select.py:110: error: Invalid index type "str | None" for "dict[str, AssistDevice]"; expected type "str" [index]
+ homeassistant/components/assist_pipeline/select.py:116: error: Argument 1 to "pop" of "dict" has incompatible type "str | None"; expected "str" [arg-type]
+ homeassistant/components/bluetooth/match.py:264: error: Item "None" of "list[BluetoothMatcher] | None" has no attribute "__iter__" (not iterable) [union-attr]
+ homeassistant/components/bluetooth/match.py:264: error: Item "None" of "list[BluetoothCallbackMatcherWithCallback] | None" has no attribute "__iter__" (not iterable) [union-attr]
+ homeassistant/components/bluetooth/passive_update_processor.py:484: error: Argument 1 to "async_set_restore_data" of "PassiveBluetoothDataUpdate" has incompatible type "RestoredPassiveBluetoothDataUpdate | None"; expected "RestoredPassiveBluetoothDataUpdate" [arg-type]
+ homeassistant/components/bluetooth/__init__.py:342: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/bluetooth/__init__.py:343: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/xbox/coordinator.py:265: error: Item "None" of "Any | None" has no attribute "last_seen_date_time_utc" [union-attr]
+ homeassistant/components/universal/media_player.py:662: error: Item "None" of "MediaPlayerEntity | None" has no attribute "async_browse_media" [union-attr]
+ homeassistant/components/tag/__init__.py:221: error: Item "None" of "RegistryEntry | None" has no attribute "name" [union-attr]
+ homeassistant/components/tag/__init__.py:221: error: Item "None" of "RegistryEntry | None" has no attribute "original_name" [union-attr]
+ homeassistant/components/tag/__init__.py:337: error: Item "None" of "RegistryEntry | None" has no attribute "name" [union-attr]
+ homeassistant/components/tag/__init__.py:337: error: Item "None" of "RegistryEntry | None" has no attribute "original_name" [union-attr]
+ homeassistant/components/search/__init__.py:572: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/search/__init__.py:573: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/search/__init__.py:574: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/schlage/coordinator.py:89: error: Item "None" of "LockData | None" has no attribute "logs" [union-attr]
+ homeassistant/components/samsungtv/bridge.py:502: error: Item "None" of "Any | None" has no attribute "get" [union-attr]
+ homeassistant/components/rfxtrx/__init__.py:442: error: Item "None" of "bytes | None" has no attribute "decode" [union-attr]
+ homeassistant/components/recorder/system_health/__init__.py:43: error: Unsupported operand types for / ("None" and "int") [operator]
+ homeassistant/components/recorder/system_health/__init__.py:43: note: Left operand is of type "float | None"
+ homeassistant/components/rainforest_raven/coordinator.py:98: error: Argument 1 to <set> has incompatible type "tuple[str, str | None]"; expected "tuple[str, str]" [arg-type]
+ homeassistant/components/portainer/coordinator.py:204: error: Item "None" of "PortainerStackData | None" has no attribute "container_count" [union-attr]
+ homeassistant/components/glances/coordinator.py:58: error: No overload variant of "__sub__" of "datetime" matches argument type "None" [operator]
+ homeassistant/components/glances/coordinator.py:58: note: Possible overload variants:
+ homeassistant/components/glances/coordinator.py:58: note: def __sub__(self, datetime, /) -> timedelta
+ homeassistant/components/glances/coordinator.py:58: note: def __sub__(self, timedelta, /) -> datetime
+ homeassistant/components/glances/coordinator.py:58: note: Right operand is of type "timedelta | None"
+ homeassistant/components/configurator/__init__.py:257: error: Incompatible types in "await" (actual type "Future[None] | None", expected type "Awaitable[Any]") [misc]
+ homeassistant/components/cloud/entity.py:331: error: Item "None" of "Match[str] | None" has no attribute "span" [union-attr]
+ homeassistant/components/api/__init__.py:428: error: Item "None" of "State | None" has no attribute "json_fragment" [union-attr]
+ homeassistant/helpers/template/extensions/floors.py:110: error: Item "None" of "FloorEntry | None" has no attribute "name" [union-attr]
+ homeassistant/helpers/template/extensions/devices.py:114: error: Item "None" of "DeviceEntry | None" has no attribute "name_by_user" [union-attr]
+ homeassistant/helpers/template/extensions/devices.py:114: error: Item "None" of "DeviceEntry | None" has no attribute "name" [union-attr]
+ homeassistant/helpers/template/extensions/areas.py:111: error: Item "None" of "DeviceEntry | None" has no attribute "area_id" [union-attr]
+ homeassistant/components/xiaomi_miio/__init__.py:391: error: Argument "title" to "async_update_entry" of "ConfigEntries" has incompatible type "str | None"; expected "str | UndefinedType" [arg-type]
+ homeassistant/components/vodafone_station/coordinator.py:127: error: No overload variant of "__sub__" of "datetime" matches argument type "None" [operator]
+ homeassistant/components/vodafone_station/coordinator.py:127: note: Possible overload variants:
+ homeassistant/components/vodafone_station/coordinator.py:127: note: def __sub__(self, datetime, /) -> timedelta
+ homeassistant/components/vodafone_station/coordinator.py:127: note: def __sub__(self, timedelta, /) -> datetime
+ homeassistant/components/vodafone_station/coordinator.py:127: note: Right operand is of type "datetime | None"
+ homeassistant/components/unifiprotect/entity.py:141: error: Argument 1 to "extend" of "list" has incompatible type "Sequence[ProtectEntityDescription[Any]] | None"; expected "Iterable[ProtectEntityDescription[Any]]" [arg-type]
+ homeassistant/components/systemmonitor/config_flow.py:47: error: Argument 1 to "async_remove" of "EntityRegistry" has incompatible type "str | None"; expected "str" [arg-type]
+ homeassistant/components/steam_online/config_flow.py:140: error: Argument 1 to "async_remove" of "EntityRegistry" has incompatible type "str | None"; expected "str" [arg-type]
... (truncated 123 lines) ...
CPython (cases_generator) (https://github.com/python/cpython)
+ Tools/cases_generator/parsing.py:397: error: Item "None" of "Token | None" has no attribute "text" [union-attr]
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/autodoc/_dynamic/_docstrings.py: note: In function "_get_docstring_lines":
+ sphinx/ext/autodoc/_dynamic/_docstrings.py:264:47: error: Argument 1 to "prepare_docstring" has incompatible type "Any | None"; expected "str" [arg-type]
+ sphinx/ext/autodoc/_dynamic/_member_finder.py: note: In function "_sort_members":
+ sphinx/ext/autodoc/_dynamic/_member_finder.py:603:68: error: Argument 1 to "enumerate" has incompatible type "Sequence[str] | None"; expected "Iterable[str]" [arg-type]
+ sphinx/ext/autodoc/_dynamic/_member_finder.py:604:34: error: Argument 1 to "len" has incompatible type "Sequence[str] | None"; expected "Sized" [arg-type]
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py: note: In member "get_doc" of class "SlotsMixin":
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2493:51: error: Argument 1 to "prepare_docstring" has incompatible type "Any | None"; expected "str" [arg-type]
pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/raises.py:1167: error: Item "RaisesExc[BaseExcT_co]" of "type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException]" has no attribute "__name__" [union-attr]
+ src/_pytest/raises.py:1167: error: Item "RaisesGroup[BaseException]" of "type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException]" has no attribute "__name__" [union-attr]
+ src/_pytest/raises.py:1218: error: Item "RaisesExc[BaseExcT_co]" of "type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException]" has no attribute "__name__" [union-attr]
+ src/_pytest/raises.py:1218: error: Item "RaisesGroup[BaseException]" of "type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException]" has no attribute "__name__" [union-attr]
mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/proxy/server.py:160: error: Argument "exc_info" to "log" of "ConnectionHandler" has incompatible type "tuple[type[BaseException] | type[None], BaseException | None, TracebackType | Any | None]"; expected "Literal[True] | tuple[type[BaseException], BaseException, TracebackType | None] | None" [arg-type]
+ mitmproxy/proxy/server.py:160: error: Item "None" of "BaseException | None" has no attribute "__traceback__" [union-attr]
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/internal/telemetry/writer.py:207: error: Argument 1 to "_get_event" of "TelemetryWriter" has incompatible type "dict[str, Any] | None"; expected "dict[str, Any] | list[Any]" [arg-type]
+ ddtrace/appsec/_trace_utils.py:98: error: Item "None" of "Span | None" has no attribute "_service_entry_span" [union-attr]
+ ddtrace/testing/internal/session_manager.py:411: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr]
pylint (https://github.com/pycqa/pylint)
+ pylint/checkers/deprecated.py:116: error: Item "None" of "Any | None" has no attribute "value" [union-attr]
jax (https://github.com/google/jax)
+ jax/_src/distributed.py:82: error: Item "None" of "str | None" has no attribute "split" [union-attr]
+ jax/_src/export/shape_poly.py:1095: error: Item "None" of "_DimFactor | None" has no attribute "operands" [union-attr]
+ jax/_src/export/shape_poly.py:1097: error: Item "None" of "_DimFactor | None" has no attribute "operands" [union-attr]
koda-validate (https://github.com/keithasaurus/koda-validate)
+ koda_validate/dictionary.py:917: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dictionary.py:950: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dictionary.py:954: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dictionary.py:1080: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dictionary.py:1111: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dictionary.py:1115: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/typeddict.py:199: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/typeddict.py:241: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/typeddict.py:245: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/namedtuple.py:206: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/namedtuple.py:257: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/namedtuple.py:261: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dataclasses.py:213: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dataclasses.py:265: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
+ koda_validate/dataclasses.py:269: error: Argument 1 to "Invalid" has incompatible type "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items> | None"; expected "CoercionErr | ContainerErr | ExtraKeysErr | IndexErrs | KeyErrs | <7 more items>" [arg-type]
CPython (peg_generator) (https://github.com/python/cpython)
+ Tools/peg_generator/pegen/grammar_parser.py:66: error: Argument 1 to "Grammar" has incompatible type "list[Rule] | None"; expected "Iterable[Rule]" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:84: error: No overload variant of "__add__" of "list" matches argument type "None" [operator]
+ Tools/peg_generator/pegen/grammar_parser.py:84: note: Possible overload variants:
+ Tools/peg_generator/pegen/grammar_parser.py:84: note: def __add__(self, list[tuple[str, str | None]], /) -> list[tuple[str, str | None]]
+ Tools/peg_generator/pegen/grammar_parser.py:84: note: def [_S] __add__(self, list[_S], /) -> list[_S | tuple[str, str | None]]
+ Tools/peg_generator/pegen/grammar_parser.py:84: note: Right operand is of type "list[tuple[str, str | None]] | None"
+ Tools/peg_generator/pegen/grammar_parser.py:104: error: Item "None" of "TokenInfo | None" has no attribute "string" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:115: error: Item "None" of "TokenInfo | None" has no attribute "string" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:126: error: Item "None" of "TokenInfo | None" has no attribute "string" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:139: error: No overload variant of "__add__" of "list" matches argument type "None" [operator]
+ Tools/peg_generator/pegen/grammar_parser.py:139: note: Possible overload variants:
+ Tools/peg_generator/pegen/grammar_parser.py:139: note: def __add__(self, list[Rule], /) -> list[Rule]
+ Tools/peg_generator/pegen/grammar_parser.py:139: note: def [_S] __add__(self, list[_S], /) -> list[_S | Rule]
+ Tools/peg_generator/pegen/grammar_parser.py:139: note: Right operand is of type "list[Rule] | None"
+ Tools/peg_generator/pegen/grammar_parser.py:169: error: Item "None" of "Rhs | None" has no attribute "alts" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:186: error: Argument 3 to "Rule" has incompatible type "Rhs | None"; expected "Rhs" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:199: error: Argument 3 to "Rule" has incompatible type "Rhs | None"; expected "Rhs" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:232: error: Argument 1 to "frozenset" has incompatible type "Any | None"; expected "Iterable[str]" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:258: error: Item "None" of "Rhs | None" has no attribute "alts" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:280: error: Item "None" of "Rhs | None" has no attribute "alts" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:289: error: Item "None" of "Rhs | None" has no attribute "alts" [union-attr]
+ Tools/peg_generator/pegen/grammar_parser.py:336: error: No overload variant of "__add__" of "list" matches argument type "None" [operator]
+ Tools/peg_generator/pegen/grammar_parser.py:336: note: Possible overload variants:
+ Tools/peg_generator/pegen/grammar_parser.py:336: note: def __add__(self, list[NamedItem], /) -> list[NamedItem]
+ Tools/peg_generator/pegen/grammar_parser.py:336: note: def [_S] __add__(self, list[_S], /) -> list[_S | NamedItem]
+ Tools/peg_generator/pegen/grammar_parser.py:336: note: Right operand is of type "list[NamedItem] | None"
+ Tools/peg_generator/pegen/grammar_parser.py:361: error: Argument 2 to "NamedItem" has incompatible type "Leaf | Group | Opt | Repeat | Forced | Lookahead | Rhs | Cut | None"; expected "Leaf | Group | Opt | Repeat | Forced | Lookahead | Rhs | Cut" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:374: error: Argument 2 to "NamedItem" has incompatible type "Leaf | Group | Opt | Repeat | Forced | Lookahead | Rhs | Cut | None"; expected "Leaf | Group | Opt | Repeat | Forced | Lookahead | Rhs | Cut" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:408: error: Argument 1 to "Forced" has incompatible type "Leaf | Group | None"; expected "Leaf | Group" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:425: error: Argument 1 to "PositiveLookahead" has incompatible type "Leaf | Group | None"; expected "Leaf | Group" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:436: error: Argument 1 to "NegativeLookahead" has incompatible type "Leaf | Group | None"; expected "Leaf | Group" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:460: error: Argument 1 to "Opt" has incompatible type "Rhs | None"; expected "Leaf | Group | Opt | Repeat | Forced | Lookahead | Rhs | Cut" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:493: error: Argument 2 to "Gather" has incompatible type "Leaf | Group | None"; expected "Leaf | Group" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:516: error: Argument 1 to "Group" has incompatible type "Rhs | None"; expected "Rhs" [arg-type]
+ Tools/peg_generator/pegen/grammar_parser.py:578: error: Unsupported operand types for + ("str" and "None") [operator]
+ Tools/peg_generator/pegen/grammar_parser.py:578: note: Right operand is of type "str | None"
+ Tools/peg_generator/pegen/grammar_parser.py:671: error: Item "None" of "TokenInfo | None" has no attribute "string" [union-attr]
egglog-python (https://github.com/egraphs-good/egglog-python)
+ python/egglog/conversion.py:165: error: Value of type "tuple[int, Callable[[Any], RuntimeExpr]] | None" is not indexable [index]
+ python/egglog/conversion.py:167: error: Value of type "tuple[int, Callable[[Any], RuntimeExpr]] | None" is not indexable [index]
poetry (https://github.com/python-poetry/poetry)
+ src/poetry/puzzle/transaction.py:155: error: Item "None" of "Any | None" has no attribute "name" [union-attr]
+ src/poetry/puzzle/transaction.py:156: error: Item "None" of "Any | None" has no attribute "name" [union-attr]
+ src/poetry/utils/env/python/manager.py:290: error: Item "None" of "Python | None" has no attribute "executable" [union-attr]
+ src/poetry/utils/env/python/manager.py:292: error: Incompatible return value type (got "Python | None", expected "Python") [return-value]
+ src/poetry/repositories/http_repository.py:181: error: Argument 2 to "getattr" has incompatible type "str | None"; expected "str" [arg-type]
+ src/poetry/publishing/uploader.py:352: error: Item "None" of "IO[bytes] | None" has no attribute "read" [union-attr]
scipy-stubs (https://github.com/scipy/scipy-stubs)
+ scripts/scipy_usage.py:385: error: Argument 1 to "add" of "set" has incompatible type "str | None"; expected "str" [arg-type]
yarl (https://github.com/aio-libs/yarl)
+ yarl/_url.py:1590:33: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr]
+ yarl/_url.py:1590:33: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
+ yarl/_url.py:1590:50: error: Item "None" of "Match[str] | None" has no attribute "start" [union-attr]
rotki (https://github.com/rotki/rotki)
+ rotkehlchen/externalapis/helius.py:260: error: Argument 1 to "deserialize_solana_address" has incompatible type "Any | None"; expected "str" [arg-type]
+ rotkehlchen/chain/ethereum/modules/eth2/eth2.py:263: error: Value of type "dict[str, dict[Any, Any]] | None" is not indexable [index]
+ rotkehlchen/chain/ethereum/modules/eth2/eth2.py:264: error: Value of type "dict[str, dict[Any, Any]] | None" is not indexable [index]
+ rotkehlchen/chain/ethereum/modules/eth2/eth2.py:266: error: Value of type "dict[str, dict[Any, Any]] | None" is not indexable [index]
xarray (https://github.com/pydata/xarray)
+ xarray/backends/netCDF4_.py: note: In member "prepare_variable" of class "NetCDF4DataStore":
+ xarray/backends/netCDF4_.py:642: error: Argument 4 to "_build_and_get_enum" has incompatible type "Any | None"; expected "str" [arg-type]
+ xarray/backends/netCDF4_.py:642: error: Argument 5 to "_build_and_get_enum" has incompatible type "Any | None"; expected "dict[str, int]" [arg-type]
freqtrade (https://github.com/freqtrade/freqtrade)
+ freqtrade/resolvers/iresolver.py:71: error: Argument 1 to "Path" has incompatible type "Any | None"; expected "str | PathLike[str]" [arg-type]
+ freqtrade/rpc/telegram.py:537: error: Argument 3 to "convert_amount" of "CryptoToFiatConverter" has incompatible type "str | None"; expected "str" [arg-type]
openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/solr/query_utils.py: note: In function "luqum_parser":
+ openlibrary/solr/query_utils.py:192: error: "None" object is not iterable [misc]
+ openlibrary/plugins/books/dynlinks.py: note: In function "add_availability":
+ openlibrary/plugins/books/dynlinks.py:458: error: Argument 1 to "get" of "dict" has incompatible type "Literal['no_ebook', 'unclassified', 'printdisabled', 'borrowable', 'public'] | None"; expected "Literal['no_ebook', 'unclassified', 'printdisabled', 'borrowable', 'public']" [arg-type]
|
This file contains hidden or 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
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.
Summary
Fixes #19430 — walrus operator (
:=) type narrowing was not being propagated when the assignment appeared inside the right operand of anandexpression.Root cause
find_isinstance_check_helper'sandbranch calledfind_isinstance_checkon both operands to collect narrowing maps, butfind_isinstance_checkonly surfaces top-levelAssignmentExprnodes (via_propagate_walrus_assignments). Walrus assignments buried deeper in the right operand — e.g. inside an arithmetic expression like(x := get_value()) + n— were silently dropped.Fix
Add
_collect_walrus_type_maptoTypeChecker. Unlike the existing_propagate_walrus_assignments, this method recurses into arbitrary expression trees (OpExpr,CallExpr,UnaryExpr,MemberExpr,IndexExpr,TupleExpr,ListExpr) looking for any nestedAssignmentExprnodes and registers each one's inferred type in the provided map.Call it in the
andbranch immediately afterfind_isinstance_check(node.right), merging results intoright_if_vars. In the true branch of(A and B), evaluation ofBis guaranteed, so all walrus assignments withinBhave definitely executed and their narrowed types should be visible.Before / after
Files changed
mypy/checker.py— new_collect_walrus_type_mapmethod + one call infind_isinstance_check_helper-SAM