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
{{ message }}
Repository navigation
non-init dataclass field overridded by property expected in init #3169
I have a dataclass with a non-init field. A subclass overrides that field with a property.
The fact that this is reported as bad override is expected, but in addition pyrefly now expects that field to be present in the dataclasses init again, even though neither with the init=False field nor the property this is required (or even allowed).
It seems like after the bad override, pyrefly expects a dataclass field, but in a different way from the field defined in the parent class.
importdataclasses@dataclasses.dataclassclassA:
foo: int=dataclasses.field(init=False)
@dataclasses.dataclassclassB(A):
pass@propertydeffoo(self) ->int: # Class member `B.foo` overrides parent class `A` in an inconsistent manner [bad-override]return1b=B() # Missing argument `foo` in function `B.__init__` [missing-argument]b=B(foo=2) # Argument `Literal[2]` is not assignable to parameter `foo` with type `(self: B) -> int` in function `B.__init__` [bad-argument-type]
Activity
rchen152 commentedon Apr 24, 2026
It looks like we report bad-override but then use the type anyway, leading to this odd hybrid behavior.
mikeleppane commentedon Jun 7, 2026
I'm working on this.
Don't treat a property override as redefining an inherited dataclass …