You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dict_kwargs in a subclass spec exists for the keyword arguments that the parameter resolvers can't determine. Resolved parameters are meant to be given through init_args. Until now dict_kwargs accepted any key for any class, so a key that the class doesn't accept was either silently ignored or only showed up as a TypeError at instantiation. Now such a key fails during parsing, unless the class has a **kwargs that the resolvers could not resolve.
Keys that are resolved parameters are still accepted in dict_kwargs and get moved to init_args. This keeps backward compatibility, and it means configs keep working when an improvement to the resolvers turns a previously unresolved parameter into a resolved one.
The parameter resolvers now track whether a **kwargs was left unresolved. They represent it with a VAR_KEYWORD parameter named **, which can't collide with a real name. Cases that count as unresolved: **kwargs not used in the body, forwarded to something that has its own unresolved **kwargs, used in an unsupported way (unsupported assign, super call or call target, given as a keyword parameter), and the assumptions and stubs resolver fallbacks. Unpack[TypedDict] counts as resolved.
This is a behavior change: configs that put a key the class doesn't accept in dict_kwargs used to parse, and now fail. The changelog entry is under Changed for v5.0.0, and the "Unresolved parameters" section of the documentation describes the new behavior.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5e494f1) to head (a2340f4). ⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.
This PR tracks unresolved **kwargs through parameter resolution and uses that information to restrict subclass dict_kwargs during parsing, help generation, and JSON Schema completion.
Records whether each generated class parser accepts arbitrary keyword names.
Moves resolved dict_kwargs parameters into init_args while rejecting unknown keys for closed signatures.
Preserves permissive behavior for genuinely unresolved forwarding and supported model extras.
Expands resolver, subclass, Pydantic, stub, and completion-schema coverage.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Resolve class signature] --> B{Unresolved **kwargs?}
B -->|Yes| C[Record accepted kwargs as True]
B -->|No| D[Record resolved names and aliases]
C --> E[Parse subclass specification]
D --> E
E --> F[Move resolved dict_kwargs keys to init_args]
F --> G{Unexpected keys remain?}
G -->|No| H[Parse init_args and retain valid unresolved kwargs]
G -->|Yes, arbitrary kwargs accepted| H
G -->|Yes, closed signature| I[Raise parsing error]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enhancementNew feature or requestrefactorImprovements to the quality of the code
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
dict_kwargsin a subclass spec exists for the keyword arguments that the parameter resolvers can't determine. Resolved parameters are meant to be given throughinit_args. Until nowdict_kwargsaccepted any key for any class, so a key that the class doesn't accept was either silently ignored or only showed up as aTypeErrorat instantiation. Now such a key fails during parsing, unless the class has a**kwargsthat the resolvers could not resolve.Keys that are resolved parameters are still accepted in
dict_kwargsand get moved toinit_args. This keeps backward compatibility, and it means configs keep working when an improvement to the resolvers turns a previously unresolved parameter into a resolved one.The parameter resolvers now track whether a
**kwargswas left unresolved. They represent it with aVAR_KEYWORDparameter named**, which can't collide with a real name. Cases that count as unresolved:**kwargsnot used in the body, forwarded to something that has its own unresolved**kwargs, used in an unsupported way (unsupported assign, super call or call target, given as a keyword parameter), and the assumptions and stubs resolver fallbacks.Unpack[TypedDict]counts as resolved.This is a behavior change: configs that put a key the class doesn't accept in
dict_kwargsused to parse, and now fail. The changelog entry is under Changed for v5.0.0, and the "Unresolved parameters" section of the documentation describes the new behavior.Before submitting