Closed aldanor closed 10 months ago
Edit: after some trial and error, it seems to work if and only if you quote 'Foo[T]'
which isn't immediately obvious from the docs, since it's valid code (e.g. with from __future__ import annotations
).
What makes it even worse is that some linters (e.g. ruff) force-strip quotes from type annotations by default (link).
@aldanor Thank you for bringing it in.
Postponed evaluation of annotations is pain in the ass. Function inspect.signature
returns string instead of ForwardRef
object in this case and we need to evaluate it. Fortunately, almost everything is ready for this since I've been working on ForwardRef
support:
I need to tweak evaluate_forward_ref
method and turn the string annotation into ForwardRef
by hand. This fix won't take much time.
In a seemingly simple example with generics, close to the one presented in the docs, mashumaro seems to stumble on
dict[str, T]
annotation; wonder if this is intended, or a bug, or some misunderstanding on my side?yields