Skip to content

Fix Tuple Special Cases from Docstrings #17440

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

Conversation

InvincibleRMC
Copy link
Contributor

Fixes #17394

(Explain how this PR changes mypy.)

Updates stubdoc is_valid_type regex.

@InvincibleRMC InvincibleRMC changed the title Fix Tuple Special Case from Docstrings Fix Tuple Special Cases from Docstrings Jun 25, 2024

This comment has been minimized.

This comment has been minimized.

@@ -20,7 +20,7 @@
Sig: _TypeAlias = Tuple[str, str]


_TYPE_RE: Final = re.compile(r"^[a-zA-Z_][\w\[\], .\"\']*(\.[a-zA-Z_][\w\[\], ]*)*$")
_TYPE_RE: Final = re.compile(r"^[a-zA-Z_][\w\[\], ().\"\']*(\.[a-zA-Z_][\w\[\], ]*)*$")

Choose a reason for hiding this comment

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

So basically this giant regex matches these:

  • a
  • abc
  • a[1], b(2).c
  • a_b.c_d
  • a.b.c

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Dec 2, 2024

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.

[Stubgenc] Fails to generate stub for Tuple special cases when using pybind11
2 participants