typing icon indicating copy to clipboard operation
typing copied to clipboard

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

Open KotlinIsland opened this issue 4 years ago • 2 comments

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 https://github.com/python/mypy/issues/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 avatar Nov 22 '21 04:11 KotlinIsland

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

JelleZijlstra avatar Nov 22 '21 04:11 JelleZijlstra

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 avatar Nov 22 '21 04:11 KotlinIsland