fix Narrow types based on collection containment #2706#2710
fix Narrow types based on collection containment #2706#2710asukaminato0721 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Improves containment-based type narrowing so that x in <typed collection> can narrow x to a finite domain derived from the RHS container’s typed element/key domain (preserving literal precision for typed dict, tuple, list, set, and frozenset, including frozenset(...) calls).
Changes:
- Add helper routines to derive a finite “membership domain” type from RHS container types (including TypedDict keys and typed container element types).
- Extend the syntactic fast-path for membership narrowing to recognize
frozenset(<literal container>). - Add a regression test covering narrowing for
inchecks against typed collection variables and inlinefrozenset(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyrefly/lib/alt/narrow.rs |
Implements finite-domain membership narrowing from typed RHS containers and recognizes inline frozenset(...) for the literal fast-path. |
pyrefly/lib/test/narrow.rs |
Adds a test ensuring in-based narrowing works for typed dict/tuple/list/set/frozenset and frozenset(("a",)). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
it's weird that mypy primer timed out, i wonder if there is a perf regression somewhere |
@yangdanny97 I've also started seeing mypy_primer timeouts in the past day or so (but only with the GitHub workflow). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@migeed-z the error count diff does not match the analysis for pydantic |
|
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D96155516. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
stroxler
left a comment
There was a problem hiding this comment.
Let's add some tests for upcasting / type erasure, and improve the behavior if we see a problem
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
containment narrowing now derives finite membership domains directly from typed RHS containers instead of relying only on the generic iterable/mapping decomposition. That preserves literal precision for typed dict, tuple, list, set, and frozenset values, and the literal fast path now also recognizes inline frozenset(...) calls
|
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
- ERROR src/pip/_vendor/urllib3/util/ssl_.py:280:66-282:14: No matching overload found for function `dict.get` called with arguments: (int | None, Literal[TLSVersion.MINIMUM_SUPPORTED]) [no-matching-overload]
- ERROR src/pip/_vendor/urllib3/util/ssl_.py:283:66-285:14: No matching overload found for function `dict.get` called with arguments: (int | None, Literal[TLSVersion.MAXIMUM_SUPPORTED]) [no-matching-overload]
- ERROR src/pip/_vendor/urllib3/util/ssl_.py:301:35-54: `int | Unknown` is not assignable to attribute `minimum_version` with type `TLSVersion` [bad-assignment]
+ ERROR src/pip/_vendor/urllib3/util/ssl_.py:301:35-54: `int` is not assignable to attribute `minimum_version` with type `TLSVersion` [bad-assignment]
- ERROR src/pip/_vendor/urllib3/util/ssl_.py:306:35-54: `int | Unknown` is not assignable to attribute `maximum_version` with type `TLSVersion` [bad-assignment]
+ ERROR src/pip/_vendor/urllib3/util/ssl_.py:306:35-54: `int` is not assignable to attribute `maximum_version` with type `TLSVersion` [bad-assignment]
prefect (https://github.com/PrefectHQ/prefect)
- ERROR src/prefect/_internal/launchers.py:64:13-29: Cannot set item in `BundleLauncherOverride` [unsupported-operation]
urllib3 (https://github.com/urllib3/urllib3)
- ERROR src/urllib3/util/ssl_.py:235:66-237:14: No matching overload found for function `dict.get` called with arguments: (int | None, Literal[TLSVersion.MINIMUM_SUPPORTED]) [no-matching-overload]
- ERROR src/urllib3/util/ssl_.py:238:66-240:14: No matching overload found for function `dict.get` called with arguments: (int | None, Literal[TLSVersion.MAXIMUM_SUPPORTED]) [no-matching-overload]
- ERROR src/urllib3/util/ssl_.py:254:35-54: `int | Unknown` is not assignable to attribute `minimum_version` with type `TLSVersion` [bad-assignment]
+ ERROR src/urllib3/util/ssl_.py:254:35-54: `int` is not assignable to attribute `minimum_version` with type `TLSVersion` [bad-assignment]
- ERROR src/urllib3/util/ssl_.py:259:35-54: `int | Unknown` is not assignable to attribute `maximum_version` with type `TLSVersion` [bad-assignment]
+ ERROR src/urllib3/util/ssl_.py:259:35-54: `int` is not assignable to attribute `maximum_version` with type `TLSVersion` [bad-assignment]
comtypes (https://github.com/enthought/comtypes)
+ ERROR comtypes/tools/codegenerator/codegenerator.py:96:30-34: Argument `Any | None` is not assignable to parameter `symbolname` with type `str` in function `comtypes.tools.codegenerator.namespaces.ImportedNamespaces.add` [bad-argument-type]
Tanjun (https://github.com/FasterSpeeding/Tanjun)
- ERROR tanjun/context/menu.py:144:16-28: Returned type `CommandType` is not assignable to declared return type `Literal[CommandType.MESSAGE, CommandType.USER]` [bad-return]
static-frame (https://github.com/static-frame/static-frame)
+ ERROR static_frame/core/interface.py:1443:28-36: `CallGuard | ContainerBase | ContainerOperand | ContainerOperandSequence | DisplayActive | DisplayConfig | IndexBase | Platform | Require | StoreConfigBase | StoreFilter | WWW` is not assignable to variable `instance` with type `ContainerBase` [bad-assignment]
mypy (https://github.com/python/mypy)
- ERROR mypyc/irbuild/util.py:142:13-23: Cannot set item in `MypycAttrs` [unsupported-operation]
- ERROR mypyc/irbuild/util.py:143:19-22: Cannot set item in `dict[MypycAttr, int]` [unsupported-operation]
core (https://github.com/home-assistant/core)
+ ERROR homeassistant/components/modbus/entity.py:308:17-82: Cannot index into `dict[str, tuple[str, str] | tuple[str, None]]` [bad-index]
+ ERROR homeassistant/components/modbus/entity.py:365:35-55: Argument `Unknown | None` is not assignable to parameter `address` with type `int` in function `homeassistant.components.modbus.modbus.ModbusHub.async_pb_call` [bad-argument-type]
pydantic (https://github.com/pydantic/pydantic)
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `allow_inf_nan` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `allowed_schemes` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `arguments_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `auto_collapse` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `choices` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `cls` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `cls_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `cls_repr` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `coerce_numbers_to_str` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `collect_init_only` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `computed_fields` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `config` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `custom_error_context` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `custom_error_message` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `custom_error_type` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `custom_init` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `dataclass_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `decimal_places` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `default` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `default_factory` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `default_factory_takes_data` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `default_host` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `default_path` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `default_port` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `definitions` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `discriminator` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `expected` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `extra_behavior` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `extras_keys_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `extras_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `fail_fast` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `fields` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `from_attributes` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `frozen` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `function_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `ge` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `generic_origin` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `gt` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `host_required` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `items_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `json_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `json_schema_input_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `keys_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `lax_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `le` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `lt` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `max_digits` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `max_length` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `members` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `microseconds_precision` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `min_length` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `missing` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `mode` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `model_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `multiple_of` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `now_op` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `now_utc_offset` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `on_error` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `pattern` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `post_init` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `python_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `regex_engine` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `return_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `revalidate_instances` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `root_model` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `schema_ref` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `slots` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `steps` [bad-typed-dict-key]
- ERROR pydantic/json_schema.py:2372:60-68: Invalid key for TypedDict `AfterValidatorFunctionSchema`, got `str` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `strict` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `strict_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `strip_whitespace` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `sub_type` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `to_lower` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `to_upper` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `total` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `tz_constraint` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `validate_by_alias` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `validate_by_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `validate_default` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `values_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `var_args_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `var_kwargs_mode` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `var_kwargs_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `variadic_item_index` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AfterValidatorFunctionSchema` does not have key `version` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `allow_inf_nan` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `allowed_schemes` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `arguments_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `auto_collapse` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `choices` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `cls` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `cls_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `cls_repr` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `coerce_numbers_to_str` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `collect_init_only` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `computed_fields` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `config` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `custom_error_context` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `custom_error_message` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `custom_error_type` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `custom_init` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `dataclass_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `decimal_places` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `default` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `default_factory` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `default_factory_takes_data` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `default_host` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `default_path` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `default_port` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `definitions` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `discriminator` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `expected` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `extra_behavior` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `extras_keys_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `extras_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `fail_fast` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `fields` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `from_attributes` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `frozen` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `function` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `function_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `ge` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `generic_origin` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `gt` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `host_required` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `items_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `json_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `json_schema_input_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `keys_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `lax_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `le` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `lt` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `max_digits` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `max_length` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `members` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `microseconds_precision` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `min_length` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `missing` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `mode` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `model_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `multiple_of` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `now_op` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `now_utc_offset` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `on_error` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `pattern` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `post_init` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `python_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `regex_engine` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `return_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `revalidate_instances` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `root_model` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `schema_ref` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `slots` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `steps` [bad-typed-dict-key]
- ERROR pydantic/json_schema.py:2372:60-68: Invalid key for TypedDict `AnySchema`, got `str` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `strict` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `strict_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `strip_whitespace` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `sub_type` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `to_lower` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `to_upper` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `total` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `tz_constraint` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `validate_by_alias` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `validate_by_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `validate_default` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `values_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `var_args_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `var_kwargs_mode` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `var_kwargs_schema` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `variadic_item_index` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `AnySchema` does not have key `version` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `allow_inf_nan` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `allowed_schemes` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `auto_collapse` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `choices` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `cls` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `cls_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `cls_repr` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `coerce_numbers_to_str` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `collect_init_only` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `computed_fields` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `config` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `custom_error_context` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `custom_error_message` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `custom_error_type` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `custom_init` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `dataclass_name` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `decimal_places` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `default` [bad-typed-dict-key]
+ ERROR pydantic/json_schema.py:2372:60-68: TypedDict `ArgumentsSchema` does not have key `default_factory` [bad-typed-dict-key]
... (truncated 4159 lines) ...
|
Primer Diff Classification❌ 1 regression(s) | ✅ 7 improvement(s) | ➖ 1 neutral | 9 project(s) total | +9, -13 errors 1 regression(s) across core. error kinds:
Detailed analysis❌ Regression (1)core (+2)
✅ Improvement (7)pip (+2, -4)
prefect (-1)
urllib3 (+2, -4)
comtypes (+1)
Tanjun (-1)
static-frame (+1)
mypy (-2)
➖ Neutral (1)pydantic (+1, -1)
Suggested fixesSummary: The new membership_narrow_container_type() for dict types, combined with the new unwrap_iterable fallback, causes false positives in the core project by over-narrowing types after 1. In the
Was this helpful? React with 👍 or 👎 Classification by primer-classifier (1 heuristic, 8 LLM) |
Summary
Fixes #2706
containment narrowing now derives finite membership domains directly from typed RHS containers instead of relying only on the generic iterable/mapping decomposition.
That preserves literal precision for typed dict, tuple, list, set, and frozenset values, and the literal fast path now also recognizes inline frozenset(...) calls
Test Plan
add the test in issue