fix: remove dead Pydantic Field and model_config from RouterConfig plain class#668
Open
totto wants to merge 1 commit into
Open
fix: remove dead Pydantic Field and model_config from RouterConfig plain class#668totto wants to merge 1 commit into
totto wants to merge 1 commit into
Conversation
RouterConfig is a plain Python class with a custom __init__, but it had:
routes: List[Route] = Field(default_factory=list)
model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True)
Neither line has any effect. Without BaseModel inheritance Pydantic never
processes Field() -- the class attribute is just set to a FieldInfo object
(which gets overwritten by __init__ anyway). ConfigDict is similarly inert.
Fix: keep the type annotation for routes (documentation value) and remove
the dead Field() default and model_config entirely.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RouterConfigis a plain Python class with a custom__init__, but it declared two Pydantic constructs that have no effect:Without
BaseModelinheritance, Pydantic never processesField()— the class attribute is set to a rawFieldInfoobject (which__init__immediately overwrites with the actual list).ConfigDictis similarly inert.Why it matters
Field(default_factory=list)sets the class attribute to aFieldInfoobject, not a list. If anything ever readsRouterConfig.routesbefore__init__runs (e.g. introspection, subclass), it gets aFieldInfoinstead of a list.Fix
Keep the type annotation
routes: List[Route]for documentation value. RemoveField()andmodel_configentirely.