Skip to content

Commit 51136ae

Browse files
committed
[python 3.11] fix monkeytype.stubs' _rewrite_container
Needs to update the special case for `Tuple[()]` for Python 3.11's python/cpython#91137 Signed-off-by: Michel Alexandre Salim <[email protected]>
1 parent 2eec653 commit 51136ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

monkeytype/stubs.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def rewrite_type_variable(self, type_variable: Any) -> str:
357357
)
358358

359359
def make_builtin_tuple(self, elements: Iterable[str]) -> str:
360-
res = ', '.join(elements)
360+
res = ", ".join(elements)
361361
return res if res else "()"
362362

363363
def make_container_type(self, container_type: str, elements: str) -> str:
@@ -593,7 +593,9 @@ def _rewrite_container(self, cls: type, container: type) -> type:
593593
args = getattr(container, "__args__", None)
594594
if args is None:
595595
return container
596-
elif args == ((),): # special case of empty tuple `Tuple[()]`
596+
elif args == ((),) or (
597+
container.__qualname__ == "Tuple" and args == ()
598+
): # special case of empty tuple `Tuple[()]`
597599
elems: Tuple[Any, ...] = ()
598600
else:
599601
# Avoid adding a suffix for the first one so that

0 commit comments

Comments
 (0)