fix in check does not narrow TypedDict Union #3079#3082
fix in check does not narrow TypedDict Union #3079#3082asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Fixes TypedDict-union narrowing when guarding with a string-literal key membership check (e.g., if "a" in foo:), addressing #3079.
Changes:
- Added a regression test asserting that
"a" in (Foo | Bar)narrows the subject toFoo(and the else branch toBar). - Updated the narrowing solver to narrow union members for
HasKey/NotHasKeyby filtering TypedDict union members based on key presence/requiredness, while preserving dict-like facet behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pyrefly/lib/test/typed_dict.rs | Adds regression test coverage for subject-type narrowing on TypedDict unions via "key" in obj. |
| pyrefly/lib/alt/narrow.rs | Implements key-membership-based narrowing across union members (esp. TypedDict) and extends dict-like detection to unions for facet handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
|
There's some discussion about how to fix this in #2199. In particularly, we can't naively narrow the TypedDict union because a non-closed TypedDict can have extra keys we can't see via subtyping. |
|
Diff from mypy_primer, showing the effect of this PR on open source code: openlibrary (https://github.com/internetarchive/openlibrary)
- ERROR openlibrary/plugins/ol_infobase.py:543:63-88: Cannot index into `list[dict[Unknown, dict[Unknown, Unknown] | list[Unknown] | Unknown] | list[dict[Unknown, Unknown] | list[Unknown] | Unknown] | Unknown]` [bad-index]
- ERROR openlibrary/plugins/openlibrary/lists.py:105:25-30: TypedDict `AnnotatedSeedDict` does not have key `key` [bad-typed-dict-key]
- ERROR openlibrary/plugins/openlibrary/lists.py:108:21-26: TypedDict `AnnotatedSeedDict` does not have key `key` [bad-typed-dict-key]
cloud-init (https://github.com/canonical/cloud-init)
- ERROR cloudinit/sources/DataSourceNoCloud.py:172:24-55: Cannot index into `str` [bad-index]
- ERROR cloudinit/sources/DataSourceNoCloud.py:172:24-55: `None` is not subscriptable [unsupported-operation]
- ERROR cloudinit/sources/DataSourceVMware.py:1001:26-27: Invalid key for TypedDict `Interface`, got `Literal[0]` [bad-typed-dict-key]
- ERROR cloudinit/sources/DataSourceVMware.py:1009:26-27: Invalid key for TypedDict `Interface`, got `Literal[0]` [bad-typed-dict-key]
- ERROR tests/unittests/sources/test_opennebula.py:159:39-73: `None` is not subscriptable [unsupported-operation]
- ERROR tests/unittests/sources/test_opennebula.py:214:37-74: `None` is not subscriptable [unsupported-operation]
mitmproxy (https://github.com/mitmproxy/mitmproxy)
- ERROR docs/src/examples/contrib/webscanner_helper/test_urldict.py:48:36-48: Cannot index into `islice[Any]` [bad-index]
- ERROR docs/src/examples/contrib/webscanner_helper/test_urldict.py:49:27-39: Cannot index into `islice[Any]` [bad-index]
- ERROR docs/src/examples/contrib/webscanner_helper/test_urldict.py:50:37-49: Cannot index into `islice[Any]` [bad-index]
- ERROR examples/contrib/webscanner_helper/test_urldict.py:48:36-48: Cannot index into `islice[Any]` [bad-index]
- ERROR examples/contrib/webscanner_helper/test_urldict.py:49:27-39: Cannot index into `islice[Any]` [bad-index]
- ERROR examples/contrib/webscanner_helper/test_urldict.py:50:37-49: Cannot index into `islice[Any]` [bad-index]
cwltool (https://github.com/common-workflow-language/cwltool)
- ERROR cwltool/command_line_tool.py:709:30-37: TypedDict `CWLDirectoryType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:709:30-37: TypedDict `CWLFileType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:710:27-38: TypedDict `CWLDirectoryType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:710:27-38: TypedDict `CWLFileType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:739:71-78: TypedDict `CWLDirectoryType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:739:71-78: TypedDict `CWLFileType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:741:50-61: TypedDict `CWLDirectoryType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:741:50-61: TypedDict `CWLFileType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:743:20-27: TypedDict `CWLDirectoryType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:743:20-27: TypedDict `CWLFileType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:757:44-54: TypedDict `DirentType` does not have key `basename` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:758:16-26: TypedDict `DirentType` does not have key `basename` [bad-typed-dict-key]
- ERROR cwltool/main.py:232:32-41: TypedDict `CWLDirectoryType` does not have key `default` [bad-typed-dict-key]
- ERROR cwltool/main.py:232:32-41: TypedDict `CWLFileType` does not have key `default` [bad-typed-dict-key]
- ERROR cwltool/main.py:241:59-65: TypedDict `CWLDirectoryType` does not have key `name` [bad-typed-dict-key]
- ERROR cwltool/main.py:241:59-65: TypedDict `CWLFileType` does not have key `name` [bad-typed-dict-key]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- ERROR sklearn/tree/_export.py:270:13-24: Object of class `_BaseTreeExporter` has no attribute `colors` [missing-attribute]
- ERROR sklearn/tree/_export.py:278:17-28: Object of class `_BaseTreeExporter` has no attribute `colors` [missing-attribute]
- ERROR sklearn/tree/_export.py:281:17-28: Object of class `_BaseTreeExporter` has no attribute `colors` [missing-attribute]
- ERROR sklearn/tree/_export.py:287:21-32: Object of class `_BaseTreeExporter` has no attribute `colors` [missing-attribute]
+ ERROR sklearn/tree/_export.py:270:13-31: Cannot set item in `object` [unsupported-operation]
+ ERROR sklearn/tree/_export.py:278:17-38: Cannot set item in `object` [unsupported-operation]
+ ERROR sklearn/tree/_export.py:281:17-38: Cannot set item in `object` [unsupported-operation]
+ ERROR sklearn/tree/_export.py:287:21-42: Cannot index into `object` [bad-index]
pwndbg (https://github.com/pwndbg/pwndbg)
- ERROR pwndbg/emu/emulator.py:481:51-63: Object of class `NoneType` has no attribute `objfile` [missing-attribute]
+ ERROR pwndbg/emu/emulator.py:481:40-63: `in` is not supported between `Literal['[heap']` and `object` [not-iterable]
- ERROR pwndbg/emu/emulator.py:525:34-46: Object of class `NoneType` has no attribute `objfile` [missing-attribute]
+ ERROR pwndbg/emu/emulator.py:525:22-46: `in` is not supported between `Literal['[stack']` and `object` [not-iterable]
- ERROR pwndbg/enhance.py:91:47-59: Object of class `NoneType` has no attribute `objfile` [missing-attribute]
+ ERROR pwndbg/enhance.py:91:36-59: `in` is not supported between `Literal['[heap']` and `object` [not-iterable]
- ERROR pwndbg/enhance.py:124:30-42: Object of class `NoneType` has no attribute `objfile` [missing-attribute]
+ ERROR pwndbg/enhance.py:124:18-42: `in` is not supported between `Literal['[stack']` and `object` [not-iterable]
apprise (https://github.com/caronc/apprise)
- ERROR apprise/plugins/dbus.py:436:49-63: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:438:53-67: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:440:48-62: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:441:53-67: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:444:42-56: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:445:52-66: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:447:42-56: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/dbus.py:448:52-66: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:396:49-63: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:398:53-67: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:400:48-62: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:401:53-67: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:404:42-56: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:405:52-66: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:407:42-56: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/glib.py:408:52-66: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/gnome.py:267:49-63: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/gnome.py:270:17-31: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/gnome.py:273:48-62: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/gnome.py:274:54-68: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/macosx.py:245:46-60: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/macosx.py:246:53-67: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/macosx.py:249:46-60: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/macosx.py:250:53-67: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1169:48-62: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1170:34-48: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1174:43-57: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1176:17-31: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1183:44-58: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1184:30-44: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1187:46-60: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1188:32-46: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1190:49-63: `None` is not subscriptable [unsupported-operation]
- ERROR apprise/plugins/telegram.py:1191:32-46: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_config.py:1290:25-38: Object of class `object` has no attribute `tags` [missing-attribute]
- ERROR tests/test_apprise_config.py:1291:27-40: Object of class `object` has no attribute `tags` [missing-attribute]
+ ERROR tests/test_apprise_config.py:1290:12-38: `in` is not supported between `Literal['company']` and `object` [not-iterable]
+ ERROR tests/test_apprise_config.py:1291:12-40: `in` is not supported between `Literal['co-worker']` and `object` [not-iterable]
- ERROR tests/test_apprise_utils.py:383:20-33: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:385:20-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:401:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:417:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:434:22-35: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:435:24-37: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:437:21-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:439:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:441:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:442:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:443:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:443:37-51: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:444:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:444:37-51: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:460:22-35: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:461:24-37: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:463:21-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:465:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:467:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:468:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:469:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:469:37-51: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:470:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:470:37-51: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1030:20-33: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1040:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1050:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1063:22-35: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1064:24-37: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1065:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1066:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1067:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_apprise_utils.py:1068:12-25: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_config_base.py:972:28-38: Object of class `object` has no attribute `tags` [missing-attribute]
+ ERROR tests/test_config_base.py:972:16-38: `in` is not supported between `Literal['devops']` and `object` [not-iterable]
- ERROR tests/test_config_base.py:997:28-38: Object of class `object` has no attribute `tags` [missing-attribute]
+ ERROR tests/test_config_base.py:997:16-38: `in` is not supported between `Literal['devops']` and `object` [not-iterable]
- ERROR tests/test_config_base.py:1180:28-38: Object of class `object` has no attribute `tags` [missing-attribute]
+ ERROR tests/test_config_base.py:1180:16-38: `in` is not supported between `Literal['devops']` and `object` [not-iterable]
- ERROR tests/test_notify_base.py:296:12-29: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:300:12-29: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:305:12-29: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:312:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:319:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:326:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:334:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:341:12-29: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:344:12-29: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:347:12-29: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:353:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:356:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:359:12-31: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:366:12-27: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_notify_base.py:371:12-27: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_ses.py:335:12-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_ses.py:337:12-36: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_ses.py:339:12-40: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_ses.py:359:12-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_ses.py:361:12-36: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_ses.py:363:12-40: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_sns.py:219:12-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_sns.py:221:12-36: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_sns.py:223:12-40: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_sns.py:242:12-34: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_sns.py:244:12-36: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_sns.py:246:12-40: `None` is not subscriptable [unsupported-operation]
speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
- ERROR backend/services/utils.py:71:16-25: Returned type `SrcErrorResultDto` is not assignable to declared return type `dict[Literal['data'], Any] | None` [bad-return]
bandersnatch (https://github.com/pypa/bandersnatch)
- ERROR src/bandersnatch/filter.py:46:25-54: `type[Any]` is not subscriptable [unsupported-operation]
pandas (https://github.com/pandas-dev/pandas)
- ERROR pandas/tests/io/test_stata.py:1866:30-44: Object of class `StataReader` has no attribute `columns` [missing-attribute]
+ ERROR pandas/tests/io/test_stata.py:1866:16-44: `in` is not supported between `Literal['date_col']` and `object` [not-iterable]
meson (https://github.com/mesonbuild/meson)
- ERROR mesonbuild/compilers/rust.py:293:40-54: Object of class `NoneType` has no attribute `id` [missing-attribute]
core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object | Unknown` is not assignable to parameter `engine` with type `str` in function `SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object | Unknown` is not assignable to parameter `use_file_cache` with type `bool | None` in function `SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object | Unknown` is not assignable to parameter `language` with type `str | None` in function `SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/__init__.py:292:53-72: Unpacked keyword argument `object | Unknown` is not assignable to parameter `options` with type `dict[Unknown, Unknown] | None` in function `SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/__init__.py:292:62-71: TypedDict `ParsedMediaSourceStreamId` does not have key `options` [bad-typed-dict-key]
- ERROR homeassistant/components/tts/__init__.py:293:41-50: TypedDict `ParsedMediaSourceStreamId` does not have key `message` [bad-typed-dict-key]
- ERROR homeassistant/components/tts/media_source.py:145:61-80: Unpacked keyword argument `object | Unknown` is not assignable to parameter `engine` with type `str` in function `homeassistant.components.tts.SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/media_source.py:145:61-80: Unpacked keyword argument `object | Unknown` is not assignable to parameter `use_file_cache` with type `bool | None` in function `homeassistant.components.tts.SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/media_source.py:145:61-80: Unpacked keyword argument `object | Unknown` is not assignable to parameter `language` with type `str | None` in function `homeassistant.components.tts.SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/media_source.py:145:61-80: Unpacked keyword argument `object | Unknown` is not assignable to parameter `options` with type `dict[Unknown, Unknown] | None` in function `homeassistant.components.tts.SpeechManager.async_create_result_stream` [bad-argument-type]
- ERROR homeassistant/components/tts/media_source.py:145:70-79: TypedDict `ParsedMediaSourceStreamId` does not have key `options` [bad-typed-dict-key]
- ERROR homeassistant/components/tts/media_source.py:146:49-58: TypedDict `ParsedMediaSourceStreamId` does not have key `message` [bad-typed-dict-key]
+ ERROR homeassistant/config_entries.py:486:17-34: Unpacked keyword argument `object | str` is not assignable to parameter `subentry_id` with type `str` in function `ConfigSubentry.__init__` [bad-argument-type]
- ERROR homeassistant/helpers/storage.py:437:17-38: Cannot index into `bool` [bad-index]
- ERROR homeassistant/helpers/storage.py:437:17-38: Cannot index into `float` [bad-index]
- ERROR homeassistant/helpers/storage.py:437:17-38: Cannot index into `int` [bad-index]
- ERROR homeassistant/helpers/storage.py:437:17-38: Cannot index into `list[JsonValueType]` [bad-index]
- ERROR homeassistant/helpers/storage.py:437:17-38: Cannot index into `str` [bad-index]
- ERROR homeassistant/helpers/storage.py:437:17-38: `None` is not subscriptable [unsupported-operation]
- ERROR homeassistant/helpers/storage.py:449:17-38: Cannot index into `bool` [bad-index]
- ERROR homeassistant/helpers/storage.py:449:17-38: Cannot index into `float` [bad-index]
- ERROR homeassistant/helpers/storage.py:449:17-38: Cannot index into `int` [bad-index]
- ERROR homeassistant/helpers/storage.py:449:17-38: Cannot index into `list[JsonValueType]` [bad-index]
- ERROR homeassistant/helpers/storage.py:449:17-38: Cannot index into `str` [bad-index]
- ERROR homeassistant/helpers/storage.py:449:17-38: `None` is not subscriptable [unsupported-operation]
- ERROR homeassistant/helpers/storage.py:458:42-63: Cannot index into `bool` [bad-index]
- ERROR homeassistant/helpers/storage.py:458:42-63: Cannot index into `float` [bad-index]
- ERROR homeassistant/helpers/storage.py:458:42-63: Cannot index into `int` [bad-index]
- ERROR homeassistant/helpers/storage.py:458:42-63: Cannot index into `list[JsonValueType]` [bad-index]
- ERROR homeassistant/helpers/storage.py:458:42-63: Cannot index into `str` [bad-index]
- ERROR homeassistant/helpers/storage.py:458:42-63: `None` is not subscriptable [unsupported-operation]
paasta (https://github.com/yelp/paasta)
- ERROR paasta_tools/kubernetes/application/controller_wrappers.py:186:47-74: Object of class `NoneType` has no attribute `config_dict` [missing-attribute]
+ ERROR paasta_tools/kubernetes/application/controller_wrappers.py:186:12-74: `in` is not supported between `Literal['unhealthy_pod_eviction_policy']` and `object` [not-iterable]
spack (https://github.com/spack/spack)
- ERROR lib/spack/spack/binary_distribution.py:1960:19-42: Object of class `NoneType` has no attribute `binary_formats` [missing-attribute]
+ ERROR lib/spack/spack/binary_distribution.py:1960:10-42: `in` is not supported between `Literal['elf']` and `object` [not-iterable]
- ERROR lib/spack/spack/mixins.py:64:41-49: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:66:21-29: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:67:42-50: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:69:25-33: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:70:41-49: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:71:42-50: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:104:37-45: Object of class `NoneType` has no attribute `spec` [missing-attribute]
- ERROR lib/spack/spack/mixins.py:106:28-36: Object of class `NoneType` has no attribute `spec` [missing-attribute]
+ ERROR lib/spack/spack/mixins.py:64:41-54: Cannot index into `object` [bad-index]
+ ERROR lib/spack/spack/mixins.py:66:12-29: `in` is not supported between `Literal['cxx']` and `object` [not-iterable]
+ ERROR lib/spack/spack/mixins.py:67:42-57: Cannot index into `object` [bad-index]
+ ERROR lib/spack/spack/mixins.py:69:12-33: `in` is not supported between `Literal['fortran']` and `object` [not-iterable]
+ ERROR lib/spack/spack/mixins.py:70:41-60: Cannot index into `object` [bad-index]
+ ERROR lib/spack/spack/mixins.py:71:42-61: Cannot index into `object` [bad-index]
+ ERROR lib/spack/spack/mixins.py:104:16-45: `not in` is not supported between `Literal['c']` and `object` [not-iterable]
+ ERROR lib/spack/spack/mixins.py:104:16-45: `not in` is not supported between `Literal['cxx']` and `object` [not-iterable]
+ ERROR lib/spack/spack/mixins.py:104:16-45: `not in` is not supported between `Literal['fortran']` and `object` [not-iterable]
+ ERROR lib/spack/spack/mixins.py:106:28-51: Cannot index into `object` [bad-index]
parso (https://github.com/davidhalter/parso)
- ERROR parso/python/pep8.py:657:41-67: Object of class `NoneType` has no attribute `prefix` [missing-attribute]
+ ERROR parso/python/pep8.py:657:29-67: `not in` is not supported between `Literal['\r']` and `object` [not-iterable]
pydantic (https://github.com/pydantic/pydantic)
- ERROR pydantic/_internal/_schema_gather.py:112:29-51: Argument `list[CoreSchema] | AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainValidatorFunctionSchema | SetSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapValidatorFunctionSchema | Unknown` is not assignable to parameter `schema` with type `AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | ComputedField | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FormatSerSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | ModelSerSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainSerializerFunctionSerSchema | PlainValidatorFunctionSchema | SetSchema | SimpleSerSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | ToStringSerSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapSerializerFunctionSerSchema | WrapValidatorFunctionSchema` in function `traverse_schema` [bad-argument-type]
+ ERROR pydantic/_internal/_schema_gather.py:112:29-51: Argument `list[CoreSchema] | object | AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainValidatorFunctionSchema | SetSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapValidatorFunctionSchema` is not assignable to parameter `schema` with type `AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | ComputedField | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FormatSerSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | ModelSerSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainSerializerFunctionSerSchema | PlainValidatorFunctionSchema | SetSchema | SimpleSerSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | ToStringSerSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapSerializerFunctionSerSchema | WrapValidatorFunctionSchema` in function `traverse_schema` [bad-argument-type]
+ ERROR pydantic/_internal/_schema_gather.py:115:22-44: Type `object` is not iterable [not-iterable]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `AfterValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `AnySchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ArgumentsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ArgumentsV3Schema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `BeforeValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `BoolSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `BytesSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `CallSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `CallableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ChainSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ComplexSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ComputedField` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `CustomErrorSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DataclassArgsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DataclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DateSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DatetimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DecimalSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DefinitionReferenceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DefinitionsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `DictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `EnumSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `FloatSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `FormatSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `IntSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `InvalidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `IsInstanceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `IsSubclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `JsonOrPythonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `JsonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `LaxOrStrictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `LiteralSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `MissingSentinelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ModelFieldsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ModelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ModelSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `MultiHostUrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `NoneSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `NullableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `PlainSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `PlainValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `SimpleSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `StringSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `TaggedUnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `TimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `TimedeltaSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `ToStringSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `TypedDictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `UnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `UrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `UuidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `WithDefaultSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `WrapSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:112:36-50: TypedDict `WrapValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `AfterValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `AnySchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ArgumentsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ArgumentsV3Schema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `BeforeValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `BoolSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `BytesSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `CallSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `CallableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ChainSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ComplexSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ComputedField` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `CustomErrorSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DataclassArgsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DataclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DateSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DatetimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DecimalSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DefinitionReferenceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DefinitionsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `DictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `EnumSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `FloatSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `FormatSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `IntSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `InvalidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `IsInstanceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `IsSubclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `JsonOrPythonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `JsonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `LaxOrStrictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `LiteralSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `MissingSentinelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ModelFieldsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ModelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ModelSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `MultiHostUrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `NoneSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `NullableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `PlainSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `PlainValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `SimpleSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `StringSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `TaggedUnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `TimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `TimedeltaSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `ToStringSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `TypedDictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `UnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `UrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `UuidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `WithDefaultSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `WrapSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:115:29-43: TypedDict `WrapValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
+ ERROR pydantic/_internal/_schema_gather.py:119:29-50: Argument `object | AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainValidatorFunctionSchema | SetSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapValidatorFunctionSchema` is not assignable to parameter `schema` with type `AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | ComputedField | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FormatSerSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | ModelSerSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainSerializerFunctionSerSchema | PlainValidatorFunctionSchema | SetSchema | SimpleSerSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | ToStringSerSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapSerializerFunctionSerSchema | WrapValidatorFunctionSchema` in function `traverse_schema` [bad-argument-type]
+ ERROR pydantic/_internal/_schema_gather.py:121:29-52: Argument `object | AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainValidatorFunctionSchema | SetSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapValidatorFunctionSchema` is not assignable to parameter `schema` with type `AfterValidatorFunctionSchema | AnySchema | ArgumentsSchema | ArgumentsV3Schema | BeforeValidatorFunctionSchema | BoolSchema | BytesSchema | CallSchema | CallableSchema | ChainSchema | ComplexSchema | ComputedField | CustomErrorSchema | DataclassArgsSchema | DataclassSchema | DateSchema | DatetimeSchema | DecimalSchema | DefinitionReferenceSchema | DefinitionsSchema | DictSchema | EnumSchema | FloatSchema | FormatSerSchema | FrozenSetSchema | GeneratorSchema | IntSchema | InvalidSchema | IsInstanceSchema | IsSubclassSchema | JsonOrPythonSchema | JsonSchema | LaxOrStrictSchema | ListSchema | LiteralSchema | MissingSentinelSchema | ModelFieldsSchema | ModelSchema | ModelSerSchema | MultiHostUrlSchema | NoneSchema | NullableSchema | PlainSerializerFunctionSerSchema | PlainValidatorFunctionSchema | SetSchema | SimpleSerSchema | StringSchema | TaggedUnionSchema | TimeSchema | TimedeltaSchema | ToStringSerSchema | TupleSchema | TypedDictSchema | UnionSchema | UrlSchema | UuidSchema | WithDefaultSchema | WrapSerializerFunctionSerSchema | WrapValidatorFunctionSchema` in function `traverse_schema` [bad-argument-type]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `AfterValidatorFunctionSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `AnySchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `ArgumentsSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `ArgumentsV3Schema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `BeforeValidatorFunctionSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `BoolSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `BytesSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:119:36-49: TypedDict `CallSchema` does not have key `keys_schema` [bad-typed-dict-key]
... (truncated 892 lines) ...
PyGithub (https://github.com/PyGithub/PyGithub)
- ERROR github/AdvisoryVulnerability.py:141:51-88: Type `NoneType` is not iterable [not-iterable]
scrapy (https://github.com/scrapy/scrapy)
+ ERROR tests/test_crawl.py:326:16-53: `not in` is not supported between `Literal['failures']` and `object` [not-iterable]
+ ERROR tests/test_crawl.py:328:39-71: Cannot index into `object` [bad-index]
+ ERROR tests/test_crawl.py:331:39-71: Cannot index into `object` [bad-index]
+ ERROR tests/test_crawl.py:334:39-71: Cannot index into `object` [bad-index]
+ ERROR tests/test_crawl.py:337:39-71: Cannot index into `object` [bad-index]
- ERROR tests/test_crawl.py:326:34-53: Object of class `NoneType` has no attribute `meta`
- Object of class `Spider` has no attribute `meta` [missing-attribute]
- ERROR tests/test_crawl.py:328:39-58: Object of class `NoneType` has no attribute `meta`
- Object of class `Spider` has no attribute `meta` [missing-attribute]
- ERROR tests/test_crawl.py:331:39-58: Object of class `NoneType` has no attribute `meta`
- Object of class `Spider` has no attribute `meta` [missing-attribute]
- ERROR tests/test_crawl.py:334:39-58: Object of class `NoneType` has no attribute `meta`
- Object of class `Spider` has no attribute `meta` [missing-attribute]
- ERROR tests/test_crawl.py:337:39-58: Object of class `NoneType` has no attribute `meta`
- Object of class `Spider` has no attribute `meta` [missing-attribute]
spark (https://github.com/apache/spark)
- ERROR python/pyspark/tests/test_util.py:37:27-45: Object of class `Wrapped` has no attribute `_input_kwargs` [missing-attribute]
- ERROR python/pyspark/tests/test_util.py:38:23-41: Object of class `Wrapped` has no attribute `_input_kwargs` [missing-attribute]
- ERROR python/pyspark/tests/test_util.py:39:27-45: Object of class `Wrapped` has no attribute `_input_kwargs` [missing-attribute]
+ ERROR python/pyspark/tests/test_util.py:37:27-50: Cannot index into `object` [bad-index]
+ ERROR python/pyspark/tests/test_util.py:38:16-41: `in` is not supported between `Literal['y']` and `object` [not-iterable]
+ ERROR python/pyspark/tests/test_util.py:39:27-50: Cannot index into `object` [bad-index]
- ERROR python/pyspark/tests/test_util.py:60:21-39: Object of class `Setter` has no attribute `_input_kwargs` [missing-attribute]
- ERROR python/pyspark/tests/test_util.py:60:55-73: Object of class `Setter` has no attribute `_input_kwargs` [missing-attribute]
- ERROR python/pyspark/tests/test_util.py:61:27-45: Object of class `Setter` has no attribute `_input_kwargs` [missing-attribute]
+ ERROR python/pyspark/tests/test_util.py:60:21-48: Cannot index into `object` [bad-index]
+ ERROR python/pyspark/tests/test_util.py:60:55-84: Cannot index into `object` [bad-index]
+ ERROR python/pyspark/tests/test_util.py:61:27-50: Cannot index into `object` [bad-index]
prefect (https://github.com/PrefectHQ/prefect)
- ERROR src/integrations/prefect-dbt/tests/core/test_orchestrator_per_node.py:998:32-55: `None` is not subscriptable [unsupported-operation]
|
Primer Diff Classification❌ 5 regression(s) | ✅ 10 improvement(s) | ➖ 5 neutral | 20 project(s) total | +58, -187 errors 5 regression(s) across apprise, speedrun.com_global_scoreboard_webapp, meson, paasta, parso. error kinds:
Detailed analysis❌ Regression (5)apprise (+5, -99)
Per-category reasoning:
speedrun.com_global_scoreboard_webapp (-1)
meson (-1)
paasta (+1, -1)
The removed The new Net effect: the old
parso (+1, -1)
✅ Improvement (10)openlibrary (-3)
The error in ol_infobase.py (line 543) is a separate issue. It involves All three were false positives — the code was correct — but they stem from different type inference limitations in pyrefly.
cloud-init (-6)
mitmproxy (-6)
cwltool (-9)
bandersnatch (-1)
core (+1, -12)
Per-category reasoning:
pydantic (+21, -21)
PyGithub (-1)
scrapy (+5)
prefect (-1)
The error occurs because However, this is a false positive because at runtime the flow returns a proper dict with dict values. The prior lines (996-997) already perform similar subscript operations (
➖ Neutral (5)scikit-learn (+4, -4)
pwndbg (+4, -4)
Per-category reasoning:
pandas (+1, -1)
spack (+9, -9)
Per-category reasoning:
spark (+6, -6)
Per-category reasoning:
Suggested fixesSummary: The new narrow_key_membership() correctly narrows TypedDict unions on 'key in x' checks, but the HasKey/NotHasKey branches unconditionally replace type_info with a reconstructed 'narrowed' value even for non-dict-like types, losing type precision and producing 'object'-typed results that cause false positive not-iterable and bad-index errors. **1. In the HasKey branch of narrow() in let narrowed_base = self.narrow_key_membership(&base_ty, key, true);
if self.has_dict_like_member(&narrowed_base) {
let mut narrowed = match &resolved_chain {
Some(chain) => type_info.with_narrow(chain.facets(), narrowed_base.clone()),
None => type_info.clone().with_ty(narrowed_base.clone()),
};
// ... facet narrowing logic ...
narrowed
} else {
type_info.clone() // <-- preserve original for non-dict-like types
}
```**
> Files: [`pyrefly/lib/alt/narrow.rs`](https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/narrow.rs)
> Confidence: high
> Affected projects: apprise, pwndbg, spack, spark, scrapy, pydantic, pandas, paasta, parso, core
> Fixes: `not-iterable`, `bad-index`, `missing-attribute`, `bad-argument-type`
> Across apprise (5 errors), pwndbg (4 errors), spack (9 errors), spark (6 errors), scrapy (5 errors), pydantic (21 errors), pandas (1 error), paasta (1 error), parso (1 error), and core (1 error), the new false positives all share the same pattern: after an `in` check on a non-TypedDict type, pyrefly infers `object` instead of the actual type, then reports not-iterable or bad-index. The root cause is that the else branch (non-dict-like types) now returns `narrowed` (reconstructed from narrow_key_membership) instead of `type_info.clone()`. For non-dict-like types, narrow_key_membership returns the type unchanged, but wrapping it in with_narrow/with_ty loses existing type context. Restoring `type_info.clone()` for the non-dict-like case preserves the pre-PR behavior for these types while keeping the TypedDict union narrowing improvement.
**2. Apply the same fix to the NotHasKey branch in [`pyrefly/lib/alt/narrow.rs`](https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/narrow.rs) (around line 1619-1640): only construct the `narrowed` variable and return it when `has_dict_like_member(&base_ty)` is true. In the else branch, return `type_info.clone()` instead of `narrowed`. Pseudo-code:
```rust
let narrowed_base = self.narrow_key_membership(&base_ty, key, false);
if self.has_dict_like_member(&base_ty) {
let mut narrowed = match &resolved_chain {
Some(chain) => type_info.with_narrow(chain.facets(), narrowed_base),
None => type_info.clone().with_ty(narrowed_base),
};
// ... facet invalidation logic ...
narrowed
} else {
type_info.clone() // <-- preserve original for non-dict-like types
}
```**
> Files: [`pyrefly/lib/alt/narrow.rs`](https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/narrow.rs)
> Confidence: high
> Affected projects: parso, spack, pwndbg
> Fixes: `not-iterable`, `bad-index`
> The NotHasKey branch has the same structural issue as HasKey. For non-dict-like types, the reconstructed `narrowed` value replaces the original type_info, potentially losing type precision. This affects the parso regression (where `not in` on a string-typed `.prefix` attribute produces an object-typed result) and spack's elif branches.
**3. In [`key_membership_value_type()`](https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/narrow.rs) in [`pyrefly/lib/alt/narrow.rs`](https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/narrow.rs) (around line 710-725), for open TypedDicts where the key is not a known field, the extra_item type defaults to `object`. When this `object` type flows into union members, it produces false positives. Consider returning the subscript inference result for open TypedDicts with unknown keys (similar to the non-TypedDict branch) rather than the raw extra_item type, or at minimum ensure the extra_item type is properly resolved. This would fix the pydantic regression where accessing keys on open TypedDicts after narrowing produces `object` in the value type union.**
> Files: [`pyrefly/lib/alt/narrow.rs`](https://github.com/facebook/pyrefly/blob/main/pyrefly/lib/alt/narrow.rs)
> Confidence: medium
> Affected projects: pydantic, core
> Fixes: `bad-argument-type`, `not-iterable`, `missing-attribute`
> In pydantic, after narrowing a union of TypedDicts via 'items_schema' in schema, some open TypedDict members that don't have 'items_schema' as a declared field contribute `object` (from ExtraItems::Default) to the value type union. This causes 21 new false positives where argument types include `object`. The fix would make key_membership_value_type return a more precise type for open TypedDicts.
</details>
---
Was this helpful? React with 👍 or 👎
<sub>Classification by primer-classifier (20 LLM)</sub> |
Summary
Fixes #3079
The solver now narrows the subject type itself for
"key" in x/"key" not in xwhen x is a TypedDict union, instead of only recording a key facet, soFoo | Barnow becomes Foo in the positive branch and Bar in the negative branch.Test Plan
add test