python / python/mypy

stubgen: mangles from _typeshed import Incomplete on Windows

Open
#16,658 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-stubgen
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report
When stubgen creates stubs for a module that imports Incomplete , it then mangles / overcomplicates the import in the generated stub
edit : On Windows

To Reproduce - minimal repro

from _typeshed import Incomplete


def polar(*args, **kwargs) -> Incomplete:
    ...

running stubgen results in

from _typeshed import Incomplete as Incomplete

def polar(*args, **kwargs) -> Incomplete: ...

Environment

  • Mypy version used: 1.7.0
  • Mypy command-line flags: - none
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11
  • OS: Windows_NT x64 10.0.26100

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 stubgen's import-generation path and reproduce the minimal example on Windows using the reported Python and mypy versions. Compare the generated import with the source and verify that the completed fix no longer emits the redundant as Incomplete alias.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
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.