Skip to content

[stubgen] C++ signature in docstring falsely included in generated stubs #18206

@mattangus

Description

@mattangus

Bug Report

When C/C++ signatures are included in the C modules docstring. It is parsed as an overload.

To Reproduce

This script for examples outputs 2 signatures:

import mypy.stubdoc

sigs = mypy.stubdoc.infer_sig_from_docstring(
    """
addLane(data: MyStruct) -> None

C++: addLane(const MyStruct data) --> void
""",
    "addLane",
)

if sigs is not None:
    for sig in sigs:
        print(sig)

Expected Behavior

There should only be one signature in the resulting stub.

Actual Behavior

there are two signatures produced

FunctionSig(name='addLane', args=[ArgSig(name='data', type='MyStruct', default=False)], ret_type='None')
FunctionSig(name='addLane', args=[ArgSig(name='constMyStructdata', type=None, default=False)], ret_type='void')

Your Environment

  • stubgen version: 1.13.0
  • Python version used: 3.12

I have a pull request to solve this, #17658

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions