python / python/mypy

stubgen: missing `__str__` method when the signature is different from default

Open
#14,696 0 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 generating a stub with classes that define __str__ with extra parameters, __str__ is missing from the generated stub.

(A clear and concise description of what the bug is.)

To Reproduce

stubgen -p PyInstaller.utils.win32.versioninfo 

Expected Behavior

Classes in the generated PyInstaller.utils.win32.versioninfo stub should define def __str__(self, indent: str = "") -> str: ...

Actual Behavior
It's missing. Which results in a stubtest failure that has to be fixed manually.

Your Environment

  • Mypy version used: mypy 1.0.0 (compiled: yes)
  • Mypy command-line flags: N/A (stubgen, see above)
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: Python 3.9.13

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 reproducing the issue with stubgen -p PyInstaller.utils.win32.versioninfo, then trace the stubgen entry point that handles __str__ methods. Done means the generated stub includes def __str__(self, indent: str = "") -> str: ... for the affected classes and avoids the reported stubtest failure.

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
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.