Skip to content

Conversation

@jwnimmer-tri
Copy link
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
Contributor

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

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

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
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.

2 participants