Skip to content

fix: remove dead Pydantic Field and model_config from RouterConfig plain class#668

Open
totto wants to merge 1 commit into
aurelio-labs:mainfrom
totto:fix/routerconfig-dead-pydantic-annotations
Open

fix: remove dead Pydantic Field and model_config from RouterConfig plain class#668
totto wants to merge 1 commit into
aurelio-labs:mainfrom
totto:fix/routerconfig-dead-pydantic-annotations

Conversation

@totto

@totto totto commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

RouterConfig is a plain Python class with a custom __init__, but it declared two Pydantic constructs that have no effect:

class RouterConfig:  # not BaseModel
    routes: List[Route] = Field(default_factory=list)  # ← FieldInfo, never processed
    model_config: ClassVar[ConfigDict] = ConfigDict(...)  # ← never applied

Without BaseModel inheritance, Pydantic never processes Field() — the class attribute is set to a raw FieldInfo object (which __init__ immediately overwrites with the actual list). ConfigDict is similarly inert.

Why it matters

  • Field(default_factory=list) sets the class attribute to a FieldInfo object, not a list. If anything ever reads RouterConfig.routes before __init__ runs (e.g. introspection, subclass), it gets a FieldInfo instead of a list.
  • The dead declarations mislead contributors into thinking RouterConfig is a Pydantic model.

Fix

Keep the type annotation routes: List[Route] for documentation value. Remove Field() and model_config entirely.

class RouterConfig:
    routes: List[Route]

    def __init__(self, routes: List[Route] = [], ...):

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant