Python 3.8 added two new typing features defined in https://docs.python.org/3/library/typing.html
After additional investigation, no support is needed in the type checker. This is runtime functionality only.
@erictraut right now pyright on Python 3.7 does not see get_args from typing_extensions for some reason:
import sys
if sys.version_info >= (3, 8):
from typing import Literal, get_args
else:
from typing_extensions import Literal, get_args
I am getting this error in VSCode:
"get_args" is unknown import symbolPyright (reportGeneralTypeIssues)
That's because get_args is not defined in typing_extensions.pyi, which comes from the typeshed repo. If you think it should be added to typing_extensions.pyi, please file a bug or a PR in that repo.
Fixed this in https://github.com/python/typeshed/commit/8ae5549b61dba441c13e762bb688b826b902246e :smile:
@HarrySky, thanks for the contribution. I'll incorporate the latest typeshed stubs into the next release of Pyright.