Skip to content

fix in check does not narrow TypedDict Union #3079 - #3082

Closed
asukaminato0721 wants to merge 2 commits into
pyrefly-org:mainfrom
asukaminato0721:3079
Closed

asukaminato0721 wants to merge 2 commits into
pyrefly-org:mainfrom
asukaminato0721:3079

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Apr 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3079

The solver now narrows the subject type itself for "key" in x / "key" not in x when x is a TypedDict union, instead of only recording a key facet, so Foo | Bar now becomes Foo in the positive branch and Bar in the negative branch.

Test Plan

add test

@meta-cla meta-cla Bot added the cla signed label Apr 9, 2026
@github-actions github-actions Bot added the size/m label Apr 9, 2026
@github-actions

This comment has been minimized.

@asukaminato0721
asukaminato0721 marked this pull request as ready for review April 9, 2026 03:59
Copilot AI review requested due to automatic review settings April 9, 2026 03:59
@asukaminato0721 asukaminato0721 changed the title fix fix in check does not narrow TypedDict Union #3079 Apr 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 to Foo (and the else branch to Bar).
  • Updated the narrowing solver to narrow union members for HasKey / NotHasKey by 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.

@github-actions

This comment has been minimized.

@rchen152

rchen152 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added size/m and removed size/m labels Apr 9, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

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

openlibrary (https://github.com/internetarchive/openlibrary)
- 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]

cwltool (https://github.com/common-workflow-language/cwltool)
- ERROR cwltool/command_line_tool.py:687:30-37: TypedDict `CWLDirectoryType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:687:30-37: TypedDict `CWLFileType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:688:27-38: TypedDict `CWLDirectoryType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:688:27-38: TypedDict `CWLFileType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:717:71-78: TypedDict `CWLDirectoryType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:717:71-78: TypedDict `CWLFileType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:719:50-61: TypedDict `CWLDirectoryType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:719:50-61: TypedDict `CWLFileType` does not have key `entryname` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:721:20-27: TypedDict `CWLDirectoryType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/command_line_tool.py:721:20-27: TypedDict `CWLFileType` does not have key `entry` [bad-typed-dict-key]
- ERROR cwltool/main.py:239:32-41: TypedDict `CWLDirectoryType` does not have key `default` [bad-typed-dict-key]
- ERROR cwltool/main.py:239:32-41: TypedDict `CWLFileType` does not have key `default` [bad-typed-dict-key]
- ERROR cwltool/main.py:248:59-65: TypedDict `CWLDirectoryType` does not have key `name` [bad-typed-dict-key]
- ERROR cwltool/main.py:248:59-65: TypedDict `CWLFileType` does not have key `name` [bad-typed-dict-key]

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_matrix.py:3632:12-26: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_plugin_pushplus.py:811:22-39: `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]

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:290:53-72: Unpacked keyword argument `object` 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:290:53-72: Unpacked keyword argument `object` 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:290:53-72: Unpacked keyword argument `object` 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:290:53-72: Unpacked keyword argument `object` 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:290:62-71: TypedDict `ParsedMediaSourceStreamId` does not have key `options` [bad-typed-dict-key]
- ERROR homeassistant/components/tts/__init__.py:291:41-50: TypedDict `ParsedMediaSourceStreamId` does not have key `message` [bad-typed-dict-key]
- ERROR homeassistant/components/tts/media_source.py:143:61-80: Unpacked keyword argument `object` 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:143:61-80: Unpacked keyword argument `object` 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:143:61-80: Unpacked keyword argument `object` 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:143:61-80: Unpacked keyword argument `object` 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:143:70-79: TypedDict `ParsedMediaSourceStreamId` does not have key `options` [bad-typed-dict-key]
- ERROR homeassistant/components/tts/media_source.py:144:49-58: TypedDict `ParsedMediaSourceStreamId` does not have key `message` [bad-typed-dict-key]
+ ERROR homeassistant/config_entries.py:484: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:432:17-38: Cannot index into `bool` [bad-index]
- ERROR homeassistant/helpers/storage.py:432:17-38: Cannot index into `float` [bad-index]
- ERROR homeassistant/helpers/storage.py:432:17-38: Cannot index into `int` [bad-index]
- ERROR homeassistant/helpers/storage.py:432:17-38: Cannot index into `list[JsonValueType]` [bad-index]
- ERROR homeassistant/helpers/storage.py:432:17-38: Cannot index into `str` [bad-index]
- ERROR homeassistant/helpers/storage.py:432:17-38: `None` is not subscriptable [unsupported-operation]
- ERROR homeassistant/helpers/storage.py:444:17-38: Cannot index into `bool` [bad-index]
- ERROR homeassistant/helpers/storage.py:444:17-38: Cannot index into `float` [bad-index]
- ERROR homeassistant/helpers/storage.py:444:17-38: Cannot index into `int` [bad-index]
- ERROR homeassistant/helpers/storage.py:444:17-38: Cannot index into `list[JsonValueType]` [bad-index]
- ERROR homeassistant/helpers/storage.py:444:17-38: Cannot index into `str` [bad-index]
- ERROR homeassistant/helpers/storage.py:444:17-38: `None` is not subscriptable [unsupported-operation]
- ERROR homeassistant/helpers/storage.py:453:42-63: Cannot index into `bool` [bad-index]
- ERROR homeassistant/helpers/storage.py:453:42-63: Cannot index into `float` [bad-index]
- ERROR homeassistant/helpers/storage.py:453:42-63: Cannot index into `int` [bad-index]
- ERROR homeassistant/helpers/storage.py:453:42-63: Cannot index into `list[JsonValueType]` [bad-index]
- ERROR homeassistant/helpers/storage.py:453:42-63: Cannot index into `str` [bad-index]
- ERROR homeassistant/helpers/storage.py:453: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]

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:111: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:111: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:114:22-44: Type `object` is not iterable [not-iterable]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `AfterValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `AnySchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ArgumentsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ArgumentsV3Schema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `BeforeValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `BoolSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `BytesSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `CallSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `CallableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ChainSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ComplexSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ComputedField` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `CustomErrorSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DataclassArgsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DataclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DateSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DatetimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DecimalSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DefinitionReferenceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DefinitionsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `DictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `EnumSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `FloatSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `FormatSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `IntSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `InvalidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `IsInstanceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `IsSubclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `JsonOrPythonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `JsonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `LaxOrStrictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `LiteralSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `MissingSentinelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ModelFieldsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ModelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ModelSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `MultiHostUrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `NoneSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `NullableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `PlainSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `PlainValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `SimpleSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `StringSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `TaggedUnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `TimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `TimedeltaSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `ToStringSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `TypedDictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `UnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `UrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `UuidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `WithDefaultSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `WrapSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:111:36-50: TypedDict `WrapValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `AfterValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `AnySchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ArgumentsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ArgumentsV3Schema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `BeforeValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `BoolSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `BytesSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `CallSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `CallableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ChainSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ComplexSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ComputedField` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `CustomErrorSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DataclassArgsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DataclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DateSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DatetimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DecimalSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DefinitionReferenceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DefinitionsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `DictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `EnumSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `FloatSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `FormatSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `IntSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `InvalidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `IsInstanceSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `IsSubclassSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `JsonOrPythonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `JsonSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `LaxOrStrictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `LiteralSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `MissingSentinelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ModelFieldsSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ModelSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ModelSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `MultiHostUrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `NoneSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `NullableSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `PlainSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `PlainValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `SimpleSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `StringSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `TaggedUnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `TimeSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `TimedeltaSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `ToStringSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `TypedDictSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `UnionSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `UrlSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `UuidSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `WithDefaultSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `WrapSerializerFunctionSerSchema` does not have key `items_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:114:29-43: TypedDict `WrapValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
+ ERROR pydantic/_internal/_schema_gather.py:118: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:120: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:118:36-49: TypedDict `AfterValidatorFunctionSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118:36-49: TypedDict `AnySchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118:36-49: TypedDict `ArgumentsSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118:36-49: TypedDict `ArgumentsV3Schema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118:36-49: TypedDict `BeforeValidatorFunctionSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118:36-49: TypedDict `BoolSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118:36-49: TypedDict `BytesSchema` does not have key `keys_schema` [bad-typed-dict-key]
- ERROR pydantic/_internal/_schema_gather.py:118: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]

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]

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

Primer Diff Classification

➖ 1 neutral | ❓ 12 needs review | 13 project(s) total | +39, -159 errors

Project Verdict Changes Error Kinds Root Cause
openlibrary ❓ Needs Review -2 bad-typed-dict-key
cwltool ❓ Needs Review -7 bad-typed-dict-key
pwndbg ❓ Needs Review +4, -4 missing-attribute, not-iterable
apprise ❓ Needs Review +5, -101 missing-attribute, not-iterable
speedrun.com_global_scoreboard_webapp ❓ Needs Review -1 bad-return
bandersnatch ❓ Needs Review -1 unsupported-operation
meson ❓ Needs Review -1 missing-attribute
core ❓ Needs Review +1, -12 bad-argument-type, bad-index
paasta ❓ Needs Review +1, -1 missing-attribute, not-iterable
parso ❓ Needs Review +1, -1 missing-attribute, not-iterable
pydantic ➖ Neutral +21, -21 Removed bad-typed-dict-key false positives narrow_key_membership()
PyGithub ❓ Needs Review -1 not-iterable
spark ❓ Needs Review +6, -6 bad-index, missing-attribute
Detailed analysis

➖ Neutral (1)

pydantic (+21, -21)

✅ Removed bad-typed-dict-key false positives: 19 errors like 'TypedDict X does not have key items_schema' were false positives — the code checks if 'items_schema' in schema before accessing, and the schema_type equality checks should narrow the union to TypedDict variants that have these keys. The type checker was failing to narrow the large AllSchemas union properly. Removing these is an improvement.
✅ Removed bad-argument-type with Unknown: 2 errors with Unknown in the type union were false positives caused by the same narrowing failure propagating Unknown types. Removing is an improvement.
❌ New bad-argument-type with object in union: 17 new errors where the narrowed type includes object (from open TypedDict extra items) making it incompatible with the parameter type. These are false positives — the code is correct at runtime since the actual values are proper CoreSchema/SerSchema/ComputedField types, not object. The object appears because the type checker is including the extra items type from open TypedDicts in the narrowed result.
❌ New not-iterable on object: 3 errors where narrowing produces a type including object and then iterating over it is flagged. False positives — the actual runtime type would be a list, not object. The object appears because the type checker is including the extra items type from open TypedDicts in the narrowed result.
❌ New missing-attribute on object: 1 error where .get() is called on a type narrowed to include object. False positive — the actual value is a dict-like TypedDict, and object is leaking in from open TypedDict extra items handling.

Overall: This is a wash — 21 false positives removed, 21 new false positives added. The old errors incorrectly flagged key access on TypedDict unions where the type checker failed to narrow the union based on schema_type equality checks. The new errors incorrectly flag values as including object in the type due to open TypedDict extra items leaking into the narrowed type. Both sets are false positives, so the net quality is roughly neutral, though the character of errors changed.

Per-category reasoning:

  • Removed bad-typed-dict-key false positives: 19 errors like 'TypedDict X does not have key items_schema' were false positives — the code checks if 'items_schema' in schema before accessing, and the schema_type equality checks should narrow the union to TypedDict variants that have these keys. The type checker was failing to narrow the large AllSchemas union properly. Removing these is an improvement.
  • Removed bad-argument-type with Unknown: 2 errors with Unknown in the type union were false positives caused by the same narrowing failure propagating Unknown types. Removing is an improvement.
  • New bad-argument-type with object in union: 17 new errors where the narrowed type includes object (from open TypedDict extra items) making it incompatible with the parameter type. These are false positives — the code is correct at runtime since the actual values are proper CoreSchema/SerSchema/ComputedField types, not object.
  • New not-iterable on object: 3 errors where narrowing produces a type including object and then iterating over it is flagged. False positives — the actual runtime type would be a list, not object. The object appears because the type checker is including the extra items type from open TypedDicts in the narrowed result.
  • New missing-attribute on object: 1 error where .get() is called on a type narrowed to include object. False positive — the actual value is a dict-like TypedDict.

Attribution: The changes to narrow_key_membership() and the NarrowOp::Atomic(subject, AtomicNarrowOp::HasKey(key)) handling in pyrefly/lib/alt/narrow.rs caused both the removal of old false positives (now narrowing on in checks) and the introduction of new false positives (open TypedDicts narrowing to include object via ExtraItems::Default).

❓ Needs Review (12)

openlibrary (-2)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CamaS9dPjLcE8Hsjw3QBm"}. Non-trivial change (0 added, 2 removed).

cwltool (-7)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CamaX871BvYmbfnvvPmnd"}. Non-trivial change (0 added, 7 removed).

pwndbg (+4, -4)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CamaaiscbivkfRPnAstVr"}. Non-trivial change (4 added, 4 removed).

apprise (+5, -101)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CamaerQukgViZbXFe2AjK"}. Non-trivial change (5 added, 101 removed).

speedrun.com_global_scoreboard_webapp (-1)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011Camai772kmcq5ncTxV7Gm"}. Non-trivial change (0 added, 1 removed).

bandersnatch (-1)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011Camam5LChTTr59Ug3rHzC"}. Non-trivial change (0 added, 1 removed).

meson (-1)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011CamapYoHLuf8D96QXMvyL"}. Non-trivial change (0 added, 1 removed).

core (+1, -12)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011Camateqn3wTVvDz5c67yk"}. Non-trivial change (1 added, 12 removed).

paasta (+1, -1)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011Camaxu6dhk49cJ6hac4eG"}. Non-trivial change (1 added, 1 removed).

parso (+1, -1)

LLM classification failed: Anthropic API returned 529: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"},"request_id":"req_011Camb4S6qXoRiUWnNexYCV"}. Non-trivial change (1 added, 1 removed).

PyGithub (-1)

LLM classification failed: All verdict votes failed. Non-trivial change (0 added, 1 removed).

spark (+6, -6)

LLM classification failed: All verdict votes failed. Non-trivial change (6 added, 6 removed).

Suggested fixes

Summary: The PR is a net improvement across most projects, but introduces false positives in pydantic (and potentially other projects) when open TypedDicts with ExtraItems::Default are narrowed via key membership, causing object to leak into the narrowed type.

1. In narrow_key_membership() in pyrefly/lib/alt/narrow.rs, when a TypedDict field is not found and the TypedDict has ExtraItems::Default, the function currently keeps the member as-is (returning member.clone()). This causes the subsequent key_membership_value_type() to return object (the default extra item type) which pollutes the narrowed type. The fix: when present=true and the key is not in fields, for ExtraItems::Default, still return member.clone() (keeping the TypedDict in the union is correct), BUT in key_membership_value_type(), when the field is not found and extra_items is ExtraItems::Default, return the field types from the TypedDict that ARE present rather than object, OR better yet, exclude the ExtraItems::Default value type from the facet narrow entirely. Specifically, in key_membership_value_type(), change the else branch for TypedDict to NOT include the extra_item type when it's ExtraItems::Default — instead skip contributing a value type for that member (return Never so it doesn't widen the union), since the key membership check on an open TypedDict with default extras doesn't give useful type information for the value.

Files: pyrefly/lib/alt/narrow.rs
Confidence: high
Affected projects: pydantic, core, apprise, paasta, parso, spark
Fixes: bad-argument-type, not-iterable, missing-attribute
The pydantic neutral analysis explicitly identifies that object appears because the type checker includes the extra items type from open TypedDicts (ExtraItems::Default) in the narrowed result. In key_membership_value_type(), when a TypedDict doesn't have the key but has ExtraItems::Default, it calls extra_item(self.stdlib) which returns object. This object type then gets unioned with the actual field types from other TypedDict variants, producing types like CoreSchema | object which trigger bad-argument-type, not-iterable, and missing-attribute errors. The fix should return Never (or skip the contribution) for ExtraItems::Default in key_membership_value_type() so that only TypedDicts that actually declare the key contribute to the value type. This would eliminate the 21 new false positives in pydantic (17 bad-argument-type, 3 not-iterable, 1 missing-attribute) and likely similar issues in other ambiguous projects.


Was this helpful? React with 👍 or 👎

Classification by primer-classifier (12 heuristic, 1 LLM)

@meta-codesync

meta-codesync Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

@rchen152 has imported this pull request. If you are a Meta employee, you can view this in D107787837.

@rchen152

rchen152 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for this PR! I kept your narrow_key_membership pruning logic and tests, but reworked how we mark the key accessible. Caching the key's value as a facet narrow masks errors on mixed unions: e.g.

def f(v: TD | list[str]):
    if "x" in v:
        v["x"]

was wrongly accepted even though a list can't be indexed by a str. I instead added a present bit to facets so we can record whether a key is present without overwriting the value, so the TypedDict resolves the key while the list still errors.

No action needed on your end - I made these changes to the imported copy of the PR.

meta-codesync Bot pushed a commit that referenced this pull request Jun 10, 2026
Summary:
For #3079.

#3082 attempts to fix the issue of erroring on a TypedDict key access after a `key in some_dict` check by overwriting `some_dict[key]` with the value type after the check. This is too coarse-grained; if `some_dict`'s type is a union with a mix of TypedDicts and non-TypedDicts, we accidentally stop type-checking subscript access on the non-TypedDict members.

The approach this stack takes is to instead add a `present` bit to `NarrowedFacet`, use it to store when a key is present without needing to write a narrowed value for it, and suppress key access errors accordingly.

This diff: adds the `present` bit.

Reviewed By: yangdanny97

Differential Revision: D107801899

fbshipit-source-id: ce7c1b96a89b2d451828b361c196e4c833673887
@meta-codesync meta-codesync Bot closed this in 28531b0 Jun 10, 2026
@meta-codesync

meta-codesync Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@rchen152 merged this pull request in 28531b0.

@meta-codesync meta-codesync Bot added the Merged label Jun 10, 2026
@asukaminato0721
asukaminato0721 deleted the 3079 branch June 10, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

in check does not narrow TypedDict Union

3 participants