Describe the Bug
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.
import dataclasses
@dataclasses.dataclass
class A:
foo: int = dataclasses.field(init=False)
@dataclasses.dataclass
class B(A):
pass
@property
def foo(self) -> int: # Class member `B.foo` overrides parent class `A` in an inconsistent manner [bad-override]
return 1
b = 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]
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABJqg6gMZSpxzwA66QQAFW7Ljz5xCYzt16CJvJgEFEgppqZhcuREwjpmAXhZs5k%2BIUgwomABSGIDYwDFUUPgEpBI2UqkZcwDFeTgmACF7FS91dC0mYklfeK1hYjpcYhhGUg0tTBgwbV17PigwLyYAWgA%2BAyM4hIS6GAYAVzp4gEYU7CZTKJ90fsH7HVwBpgAmYZAAGhAyVrAoUkIGXCooCgBiJgAFUhW1pjQsPHwmDlx0SABzTrYIW8JBfYBlGBgmAAsGBjEOCIAD0IOWRTWhHo9xBMHQIMwuA4cBBNzuEEedGetxBJToTFQADdUNBUNhYNdbg8ngwXvEsnTbtJBGQGL9btUiTk4PSpvwQABmQjdaYCwQAbRymTocAAuoJ2uhqLRGDBMNVMBBWhw6dypgByTHoegwA2CE0MaqtACO7W16uqAGsYKRqpwOPBwqYDQB3VBdc3oEAAX0WnD1MFc0BgFHOOAIJHIIaAA
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
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=Falsefield 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.
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABJqg6gMZSpxzwA66QQAFW7Ljz5xCYzt16CJvJgEFEgppqZhcuREwjpmAXhZs5k%2BIUgwomABSGIDYwDFUUPgEpBI2UqkZcwDFeTgmACF7FS91dC0mYklfeK1hYjpcYhhGUg0tTBgwbV17PigwLyYAWgA%2BAyM4hIS6GAYAVzp4gEYU7CZTKJ90fsH7HVwBpgAmYZAAGhAyVrAoUkIGXCooCgBiJgAFUhW1pjQsPHwmDlx0SABzTrYIW8JBfYBlGBgmAAsGBjEOCIAD0IOWRTWhHo9xBMHQIMwuA4cBBNzuEEedGetxBJToTFQADdUNBUNhYNdbg8ngwXvEsnTbtJBGQGL9btUiTk4PSpvwQABmQjdaYCwQAbRymTocAAuoJ2uhqLRGDBMNVMBBWhw6dypgByTHoegwA2CE0MaqtACO7W16uqAGsYKRqpwOPBwqYDQB3VBdc3oEAAX0WnD1MFc0BgFHOOAIJHIIaAA
(Only applicable for extension issues) IDE Information
No response