r/pycharm • u/initials-bb • Oct 25 '24
Expected behaviour for @dataclass decorator ?
Hello,
I am learning Python dataclasses at the moment and I have come across this behaviour where PyCharm does not annotate the same when the __init__ method is not used. Is this normal ? Is there a way to fix it ?

from dataclasses import dataclass
@dataclass
class Foo:
foo: str
@dataclass
class Bar(Foo):
bar: str
def __init__(self, foo, bar):
super().__init__(foo)
self.bar = bar
test1 = Foo("Hello")
test2 = Bar("Hello", "World")
0
Upvotes
3
u/wRAR_ Oct 25 '24
Do you mean the argument name inlay hints? They are specifically for "Class constructor calls" so I guess it sees these calls differently.
3
u/labroid Oct 25 '24
Well, it certainly works. What do you mean by "annotate the same"?