Skip to content

Commit e105410

Browse files
committed
AnnotationTemplate is strict on nesting type
1 parent 3a696f2 commit e105410

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pyannotating.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class AnnotationTemplate(_AnnotationFactory):
6969
7070
Templateizes Union.
7171
72+
Recognize nesting of annotations only by `list` i.e
73+
```
74+
AnnotationTemplate(Callable, [[input_annotation], Any]) # works
75+
AnnotationTemplate(Callable, [(input_annotation, ), Any]) # does not work
76+
```
77+
7278
Delegates responsibilities to other templates when passing them as
7379
annotations.
7480
"""
@@ -109,7 +115,7 @@ def __get_formatted_annotations_from(self, annotations: Iterable, replacement_an
109115
if isinstance(annotation, InputAnnotationAnnotation):
110116
annotation = replacement_annotation
111117

112-
elif isinstance(annotation, Iterable) and not isinstance(annotation, str):
118+
elif isinstance(annotation, list):
113119
annotation = self.__get_formatted_annotations_from(
114120
annotation,
115121
replacement_annotation

0 commit comments

Comments
 (0)