python / python/mypy

make stubgen generate PEP-561/typing docs compliant '-stubs' package directory names

Open
#17,764 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report

the stubgen --output doesn't generate package directories named as mandated by PEP-561/the typing docs.

PEP-561 states that "The name of the stub package MUST follow the scheme foopkg-stubs for type stubs for the package named foopkg."

To Reproduce and Actual Behavior

currently the packages in are placed into subdirectories named like the package.
so for a package foobar, the stubs currently are generated into a out/foopkg directory, where out is the default for the --output parameter to stubgen, like so:

$ stubgen --inspect-mode --ignore-errors --package mypy
... lots of output
$ find out -type d
out/
out/mypy
out/mypy/server
out/mypy/plugins
out/mypy/dmypy

Expected Behavior

the output should instead have a -stubs suffix to the üpackage name, out/foopkg-stubs, like so:

$ stubgen --inspect-mode --ignore-errors --package mypy
... lots of output
$ find out -type d
out/
out/mypy-stubs
out/mypy-stubs/server
out/mypy-stubs/plugins
out/mypy-stubs/dmypy

Your Environment

$ pip list
Package           Version
----------------- -------
mypy              1.11.2
mypy-extensions   1.0.0
$ python --version
Python 3.12.6

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 the stubgen CLI's --output handling and reproduce the package generation using the --inspect-mode, --ignore-errors, and --package options shown in the report. Trace where package directories are named, then verify that generated package stubs use the required -stubs suffix and preserve their nested modules.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.