python / python/mypy

Emit PEP 585 syntax from stubgen

Open
#16,737 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-pep-585 topic-stubgen
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Feature

stubgen currently does not emit PEP 585 syntax, it should, it is permissible, and typeshed has been using PEP 585 syntax for a long while now.

For example, stubgen outputs the following non-PEP-585 syntax in the most current version.

from typing import Tuple

def get_sim_time() -> Tuple[int, int]: ...

Pitch

stubgen should output PEP-585 syntax.

def get_sim_time() -> tuple[int, int]: ...

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 by locating stubgen's annotation-generation entry point and reproduce the shown function example. Trace where typing.Tuple is selected, then verify that generated annotations use tuple[int, int] without the unnecessary typing import. Done means stubgen emits PEP 585 syntax consistently for the affected built-in generic types.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.