From 4f6fab6a5d19e3b5e59f4dbe583b7cb1c5b0cb0f Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 25 Jun 2024 16:24:31 -0400 Subject: [PATCH 1/3] update regex --- mypy/stubdoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/stubdoc.py b/mypy/stubdoc.py index 8c0a4dab696f..a5d290c3cd85 100644 --- a/mypy/stubdoc.py +++ b/mypy/stubdoc.py @@ -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\[\], ]*)*$") _ARG_NAME_RE: Final = re.compile(r"\**[A-Za-z_][A-Za-z0-9_]*$") From 9f20e36a38486159bf21941f4adeaf9ff8a93ca0 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 25 Jun 2024 16:27:58 -0400 Subject: [PATCH 2/3] update test cases --- mypy/test/teststubgen.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mypy/test/teststubgen.py b/mypy/test/teststubgen.py index 3669772854cb..3e9637f0f511 100644 --- a/mypy/test/teststubgen.py +++ b/mypy/test/teststubgen.py @@ -1357,6 +1357,9 @@ def test_is_valid_type(self) -> None: assert is_valid_type("List[int]") assert is_valid_type("Dict[str, int]") assert is_valid_type("None") + assert is_valid_type("tuple[int]") + assert is_valid_type("tuple[()]") + assert is_valid_type("tuple[int, ...]") assert not is_valid_type("foo-bar") assert not is_valid_type("x->y") assert not is_valid_type("True") From ab83a68db97dcdad82bce31374b89ce611c793ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Jun 2024 23:37:47 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/stubdoc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mypy/stubdoc.py b/mypy/stubdoc.py index 65642d604380..99d3d751b6b9 100644 --- a/mypy/stubdoc.py +++ b/mypy/stubdoc.py @@ -20,7 +20,6 @@ Sig: _TypeAlias = Tuple[str, str] - _TYPE_RE: Final = re.compile(r"^[a-zA-Z_][\w\[\], ().\"\']*(\.[a-zA-Z_][\w\[\], ]*)*$") _ARG_NAME_RE: Final = re.compile(r"\**[A-Za-z_][A-Za-z0-9_]*$")