Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use _typeshed in TYPE_CHECKING block #479

Open
nineteendo opened this issue Sep 11, 2024 · 3 comments
Open

Can't use _typeshed in TYPE_CHECKING block #479

nineteendo opened this issue Sep 11, 2024 · 3 comments

Comments

@nineteendo
Copy link

Example:

if TYPE_CHECKING:
    from _typeshed import StrPath

def foo(path: StrPath) -> StrPath:
    return path

Output (fails a build on read the docs):

WARNING: Failed guarded type import with ModuleNotFoundError("No module named '_typeshed'")

Stubs for _typeshed: https://github.com/python/typeshed/tree/main/stdlib/_typeshed

@gaborbernat
Copy link
Member

I do not see how we can solve this, but if someone has ideas PR welcome. I would say for now do not use _typeshed imports.

@nineteendo
Copy link
Author

Yeah, unless this can be implemented without executing the code block?

@gaborbernat
Copy link
Member

The code block needs to be executed, otherwise we wouldn't be able to resolve some of the objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants