Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/stubdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

_ARG_NAME_RE: Final = re.compile(r"\**[A-Za-z_][A-Za-z0-9_]*$")


Expand Down
3 changes: 3 additions & 0 deletions mypy/test/teststubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,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 is_valid_type("Literal[26]")
assert is_valid_type("Literal[0x1A]")
assert is_valid_type('Literal["hello world"]')
Expand Down