python / python/typing

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

Open
#955 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: feature
Dominant language
Python
Stars
1.8k
Forks
302
Avg merge
23h
Merged PRs (30d)
8

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the requested typing.type_check_only behavior for variables and import statements, then read the related issue #11503 about fictitious module imports in stubs. Done means the desired type-time-only semantics and import behavior are clearly specified and agreed upon.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.