<#4706 [BUG] Flytekit python unable to parse `int ...
# flytekit
a
#4706 [BUG] Flytekit python unable to parse `int | None` style type hints on python3.11 Issue created by kumare3 Describe the bug 3.11 support
int|None
as a way of specifying optional and union types. But flytekit TypeEngine resolves this to pickle as it does not understand that it is infact a union. But if you use
typing.Union[int, None]
or
typing.Optional[int]
these work fine. On 3.9 python has an error and flytekit bubbles this error
Copy code
def double(x: int | None) -> int:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
Flytekit bubble
Copy code
Failed with Unknown Exception <class 'TypeError'> Reason: unsupported operand type(s) for |: 'type' and 'NoneType'
and also an associated Long stack trace, that originates in import lib. We can simplify this and simply show the same error as python Expected behavior
def foo(t: int|None):
or
def foo(t: Optional[int])
both should work Additional context to reproduce No response Screenshots No response Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte