Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 1cfd223

Browse files
committed
Fix parsing of empty tuple type Tuple[()]
1 parent 794615b commit 1cfd223

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

rewrite/rewrite/python/_parser_visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ def __convert_type_mapper(self, node) -> Optional[TypeTree]:
19081908
None
19091909
)
19101910
elif isinstance(node, ast.Subscript):
1911-
slices = node.slice.elts if isinstance(node.slice, ast.Tuple) else [node.slice]
1911+
slices = [node.slice]
19121912
return j.ParameterizedType(
19131913
random_id(),
19141914
self.__whitespace(),

rewrite/tests/python/all/type_hint_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ def test_union_type():
124124
rewrite_run(python("""foo: None | ... = None"""))
125125

126126

127+
def test_empty_tuple_type():
128+
# language=python
129+
rewrite_run(python('''
130+
from typing import Tuple
131+
foo: Tuple[()] = None
132+
''')
133+
)
134+
135+
127136
def test_function_parameter_with_quoted_type_hint():
128137
# language=python
129138
rewrite_run(

0 commit comments

Comments
 (0)