MCPcopy Create free account
hub / github.com/Kitware/VTK / annotation_text

Function annotation_text

Wrapping/Python/vtkmodules/generate_pyi.py:188–216  ·  view source on GitHub ↗

Return the new text to be used for an annotation.

(a, text, is_return)

Source from the content-addressed store, hash-verified

186 sys.stderr.write('-' * (pos - begin) + "^\n")
187
188def annotation_text(a, text, is_return):
189 """Return the new text to be used for an annotation.
190 """
191 if isinstance(a, ast.Name):
192 name = a.id
193 if name not in types:
194 # quote the type, in case it isn't yet defined
195 text = '\'' + name + '\''
196 elif isinstance(a, (ast.Tuple, ast.List)):
197 size = len(a.elts)
198 e = a.elts[0]
199 offset = a.col_offset
200 old_name = text[e.col_offset - offset:e.end_col_offset - offset]
201 name = annotation_text(e, old_name, is_return)
202
203 if is_return:
204 # use concrete types for return values
205 if isinstance(a, ast.Tuple):
206 text = 'Tuple[' + ', '.join([name]*size) + ']'
207 else:
208 text = 'List[' + name + ']'
209 else:
210 # use generic sequence types for args
211 if isinstance(a, ast.Tuple):
212 text = 'Sequence[' + name + ']'
213 else:
214 text = 'MutableSequence[' + name + ']'
215
216 return text
217
218def fix_annotations(signature):
219 """Fix the annotations in a method definition.

Callers 1

fix_annotationsFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected