Skip to content

Upgrade typing.type_check_only to be applicable to variables(and maybe import statements) #955

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

Open
KotlinIsland opened this issue Nov 22, 2021 · 2 comments
Labels
topic: feature Discussions about new features for Python's type annotations

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Nov 22, 2021

from typing import _KT, _promote

Success: no issues found in 1 source file

Sure it has an underscore, but seems super sus that there is no mechanism to specify that a variable in a stub is just a type time helper and has no bearing on reality whatsoever.

You can specify explicitly that an import is accessible by importing it with an alias, although this in itself looks extremely hacky/workaroundy.

Also if it were possible to mark something in a stub as 'type time' only, then you could remove all the underscores and make a bunch of types look a lot nicer.

Very much related to python/mypy#11503, where a module import in a stub can be completely fictitious, and there is currently no way to specify it one way or the other.

@KotlinIsland KotlinIsland added the topic: feature Discussions about new features for Python's type annotations label Nov 22, 2021
@JelleZijlstra
Copy link
Member

https://docs.python.org/3/library/typing.html#typing.type_check_only

@KotlinIsland
Copy link
Contributor Author

Ironically:

from typing import type_check_only

Success: no issues found in 1 source file

Okay, that's a pretty good one, it sucks that it's not applicable to variables(TypeVars, type aliases) or import statements.

I'll update the issue.

@KotlinIsland KotlinIsland changed the title Add a method to specify that something is not accessable Upgrade typing.type_check_only to be applicable to variables(and maybe import statements) Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: feature Discussions about new features for Python's type annotations
Projects
None yet
Development

No branches or pull requests

2 participants