Skip to content

Pydantic frozen=False override does not make subclass fields writable #4513

Description

@sharkdp

The following write to the Child.text attribute is incorrectly rejected by ty:

from pydantic import BaseModel, ConfigDict

class Frozen(BaseModel):
    model_config = ConfigDict(frozen=True)

class Mutable(Frozen):
    model_config = ConfigDict(frozen=False)

class Child(Mutable):
    text: str

child = Child(text="before")
child.text = "after"  # Should be accepted.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpydanticIssues related to ty's pydantic support

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions