Skip to content

stubgen: Fix mis-parsing of double colon ("::")#20285

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
jwnimmer-tri:double-colon
Nov 22, 2025
Merged

stubgen: Fix mis-parsing of double colon ("::")#20285
ilevkivskyi merged 1 commit into
python:masterfrom
jwnimmer-tri:double-colon

Conversation

@jwnimmer-tri

Copy link
Copy Markdown
Contributor

When parsing the docstrings of a function to find its set of overloads, C++ code samples that mention the function name were at risk of matching the C++ scoping operator "::" as a type annotation, leading to malformed output. For example "MyFunc(foo: int) -> bool" is a valid signature, but the sample code "MyFunc(Eigen::Lower)" was being mis-parsed. Fix this by patching stubgen to reset in case it sees a double colon where a single colon "name: type" stanza was expected.

When parsing the docstrings of a function to find its set of overloads,
C++ code samples that mention the function name were at risk of matching
the C++ scoping operator "::" as a type annotation, leading to malformed
output. For example "MyFunc(foo: int) -> bool" is a valid signature, but
the sample code "MyFunc(Eigen::Lower)" was being mis-parsed. Fix this by
patching stubgen to reset in case it sees a double colon where a single
colon "name: type" stanza was expected.
@github-actions

Copy link
Copy Markdown
Contributor

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

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks!

@ilevkivskyi
ilevkivskyi merged commit a749368 into python:master Nov 22, 2025
22 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in GC-Content-Calculator Dec 12, 2025
@jwnimmer-tri
jwnimmer-tri deleted the double-colon branch January 27, 2026 15:35
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.

3 participants