Closed aaltat closed 3 years ago
Doesn't PLC just forward __annotations__
to RF? If yes, this ought to work with RF 4.1.1 and newer out of the box. Adding explicit tests is definitely a good idea anyway.
Yes, it does forwards. If there is no changes in that area, things will most likely just work. But testing it out, is always a good idea.
PLC could actually convert x | y
into (x, y)
that RF handles as well. The benefit would be that then using x | y
syntax would work also with older RF versions. I doubt that's worth the effort, though. People using Python 3.10 are likely to use latest RF version as well.
I need to check, I think that is tested in unit level, but I used the Py3.10 in acceptance tests.
The x | y
syntax requires Python 3.10 so no point testing with older. But it also requires RF 4.1.1 because x | y
is actually types.UnionType
and earlier RF versions don't support that. If PLC would convert types.UnionType
to a tuple (just accessing its __args__
is enough), it would work also with earlier RF 4 versions. Implementation would be something like
try:
from types import UnionType
except ImportError:
UnionType = ()
...
if isintance(typ, UnionType):
typ = typ.__args__
PLC might actually do it already. Just need test and check how it goes in the code.
3.10 brings new way to present type hints. Make sure that example this works: