Pyright: Add support for get_origin and get_args, new 3.8 features

Created on 25 Oct 2019  路  5Comments  路  Source: microsoft/pyright

Python 3.8 added two new typing features defined in https://docs.python.org/3/library/typing.html

enhancement request

All 5 comments

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.

@HarrySky, thanks for the contribution. I'll incorporate the latest typeshed stubs into the next release of Pyright.

Was this page helpful?
0 / 5 - 0 ratings