-
-
Notifications
You must be signed in to change notification settings - Fork 398
Open
Labels
TypingTyping/stub/Mypy/PyRight related bugs.Typing/stub/Mypy/PyRight related bugs.
Description
While #1451 added support for forward references in the classes themselves, forward references in converter functions still fail due to the use of inspect.signature
which by default uses Format.VALUE
when getting annotations.
Example:
from attrs import define, field
@define
class Works:
x: unknown1
def converter(x: unknown2 | str) -> str:
return str(x)
@define
class Fails:
x: str = field(converter=converter)
Result:
NameError: name 'unknown2' is not defined
Cause:
Line 50 in 1315e42
self.sig = inspect.signature(callable) |
For Python 3.14 annotations you now need:
self.sig = inspect.signature(callable, annotation_format=annotationlib.Format.FORWARDREF)
Metadata
Metadata
Assignees
Labels
TypingTyping/stub/Mypy/PyRight related bugs.Typing/stub/Mypy/PyRight related bugs.