python / python/mypy

The "include-docstrings" option doesn't work

Open
#16,114 2 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

After cloning the latest Mypy version available on GitHub, I see the "include-docstrings" option available, but running stubgen on an extension module that provides docstrings results in no docstrings at all.

To Reproduce

git clone https://github.com/python/mypy.git
python -m build
python -m pip install mypy-1.7.0+dev-py3-none-any.whl
stubgen --include-docstrings -p myextmodule[.pyd]
python -m mypy.stubgen --include-docstrings -p myextmodule[.pyd]

Expected Behavior

The .pyi file generated from stubgen should contain docstrings declared in the extension module, for classes and functions.

Actual Behavior

There is no docstrings at all, but they exist in the extension module. I have confirmed using help(myextmodule).

Your Environment

python 3.11 for Windows x64
myextmodule installed onto site-packages

  • Mypy version used: 1.7.0+dev
  • Mypy command-line flags: --include-docstrings -p myextmodule
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: cp3.11

I know this is a new feature, but it seems not to work out.

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 entry points used by stubgen --include-docstrings and python -m mypy.stubgen, then reproduce the behavior against an extension module on Python 3.11. Trace how the option handles classes and functions, and verify that the generated .pyi includes their existing docstrings.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.