-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Description
Hi,
at first, thank You for the great library. =)
For code
from __future__ import annotations
from pyfields import field
class Foo:
bar: Foo = field()
I got RuntimeError: Error calling __set_name__ on 'NativeField' instance 'bar' in 'Foo'. It is because class Foo does not exist yet and field calls typing.get_type_hints at line 299.
python-pyfields/pyfields/core.py
Lines 293 to 300 in e19ab12
| def __set_name__(self, | |
| owner, # type: Type[Any] | |
| name # type: str | |
| ): | |
| if owner is not None: | |
| # fill all the information about how it is attached to the class | |
| cls_type_hints = get_type_hints(owner) | |
| self.set_as_cls_member(owner, name, owner_cls_type_hints=cls_type_hints) |
For now I just don't annotate attributes like this, but it is weird (and inconsistent) that some attributes have typing annotation and some don't. =)
I'm not sure where and how to fix it.
Metadata
Metadata
Assignees
Labels
No labels