Skip to content

Conversation

@chadrik
Copy link
Contributor

@chadrik chadrik commented Nov 2, 2025

The DocStringParser was previously discarding / and * separators when parsing function signatures from docstrings, leading to inaccurate stub generation for functions with positional-only or keyword-only arguments.

Changes:

  • Add / and * as ArgSig entries in parsed function signatures
  • Fix state reset logic to properly handle multiple signatures with separators

DocStringParser is used by infer_sig_from_docstring which is the primary entry-point for all docstring parsing. Stripping positional-only and kw-only separators is a form of data loss: it means that any SignatureGenerator that intends to use these parsed signatures (such as mypy.stubgenc.DocstringSignatureGenerator) will generate inaccurate stubs.

Additionally, any signatures that possessed / or * failed to parse multiple overloads. I added tests that confirm multiple overloads could be successfully parsed by infer_sig_from_docstring, and fixed the problems related to / or * args.

…nly argument separators

The DocStringParser was previously discarding `/` and `*` separators when parsing function signatures from docstrings, leading to inaccurate stub generation for functions with positional-only or keyword-only arguments.

Changes:
- Add `/` and `*` as ArgSig entries in parsed function signatures
- Fix state reset logic to properly handle multiple signatures with separators
@chadrik chadrik force-pushed the stubgen/parse-pos-kw-only branch from 0cca449 to 13a060c Compare November 2, 2025 04:24
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant