Код: Выделить всё
@dataclass
class FirstDataClass:
some_attribute: int
@dataclass
class SecondDataClass:
some_attribute_2: int
class Aggregator:
@property
def first_class(self):
return FirstDataClass
@property
def second_class(self):
return SecondDataClass
FirstDataClass(some_attribute=3) # all works well here, Pycharm shows me the hint about attribute
Aggregator().first_class(some_attribute=3) # but here Pycharm says that Unexpected argument is
# given and doesn't show any suggestions
first_class = Aggregator().first_class # although get_type_hints shows the correct arguments
print(typing.get_type_hints(first_class)) # {{'some_attribute': }
Я пробовал использовать аннотации типа -> Type[FirstDataClass] или ClassVar[FirstDataClass] — не помогает. Это ошибка Pycharm и есть ли способ получать подсказки?
Подробнее здесь: https://stackoverflow.com/questions/705 ... ataclasses