python / python/typeshed

Remove type checker-specific symbols from builtins.pyi and typing.pyi

Open
#7,580 22 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stubs: improvement
Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

I'm working to get rid of the type checker-specific symbols that currently are in our core stubs but don't exist at runtime. I'll use this issue to track the work needed. This involves changes both to typeshed and to type checkers.

Affected names:

  • typing._TypedDict. Suggesting to rename to _typeshed.TypedDictFallback. (mypy and pyright)
  • typing._promote -> _typeshed._promote (mypy only)
  • typing.AwaitableGenerator -> _typeshed.AwaitableGenerator (mypy and pyright)
  • builtins.function (mypy and pyright). Need to look more into why we can't just use types.FunctionType.
    • Working on this in mypy but it requires updating a ton of test cases
  • builtins.ellipsis (mypy and pyright). Should add a new name to _typeshed, similar to NoneType.

builtins.module was also mentioned in the past but it's been fixed already (mypy PR: https://github.com/python/mypy/pull/3107).

Linked issues and PRs:

Contributor guide

Open the contributing guide

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 with builtins.pyi and typing.pyi, then review the linked typeshed and type-checker issues to understand the required replacements. Check the affected mypy and pyright behavior and test cases, especially the builtins.function cases. Done means the type-checker-specific symbols are removed from the core stubs and the affected type-checker tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.