Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stubgen] infer_sig_from_docstring fails with python3.12 inline generic #17447

Open
InvincibleRMC opened this issue Jun 27, 2024 · 2 comments · May be fixed by #17559
Open

[stubgen] infer_sig_from_docstring fails with python3.12 inline generic #17447

InvincibleRMC opened this issue Jun 27, 2024 · 2 comments · May be fixed by #17559
Labels
bug mypy got something wrong topic-pep-695 Issues related to PEP 695 syntax topic-stubgen

Comments

@InvincibleRMC
Copy link
Contributor

Bug Report

Trying to infer types from docstrings with python3.12 inline generics fails to generate.

To Reproduce

from mypy.stubdoc import infer_sig_from_docstring
infer_sig_from_docstring('\nfunc[T, V](x: T, y: V) -> T', 'func')

Expected Behavior

infer_sig_from_docstring('\nfunc[T, V](x: T, y: V) -> T', 'func') ==
            [
                FunctionSig(
                    name="func", args=[ArgSig(name="x", type="T"), ArgSig(name="y", type="V")], ret_type="T"
                )
            ]

Actual Behavior

infer_sig_from_docstring('\nfunc[T, V](x: T, y: V) -> T', 'func') == []

Your Environment

  • Mypy version used: 1.11.dev
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: python 3.10
@InvincibleRMC InvincibleRMC added the bug mypy got something wrong label Jun 27, 2024
@AlexWaygood AlexWaygood added topic-stubgen topic-pep-695 Issues related to PEP 695 syntax labels Jun 27, 2024
@AlexWaygood
Copy link
Member

@hamdanal, might be of interest to you? :)

@InvincibleRMC
Copy link
Contributor Author

Following up it would be very helpful if stubgen could generate the following automatically

from typing import TypeVar
T = TypeVar("T")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-695 Issues related to PEP 695 syntax topic-stubgen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants