MCPcopy Index your code
hub / github.com/python/mypy / generate_variable_stub

Method generate_variable_stub

mypy/stubgenc.py:910–920  ·  view source on GitHub ↗

Generate stub for a single variable using runtime introspection. The result lines will be appended to 'output'. If necessary, any required names will be added to 'imports'.

(self, name: str, obj: object, output: list[str])

Source from the content-addressed store, hash-verified

908 output.append(f"{self._indent}class {class_name}{bases_str}: ...")
909
910 def generate_variable_stub(self, name: str, obj: object, output: list[str]) -> None:
911 """Generate stub for a single variable using runtime introspection.
912
913 The result lines will be appended to 'output'. If necessary, any
914 required names will be added to 'imports'.
915 """
916 if self.is_private_name(name, f"{self.module_name}.{name}") or self.is_not_in_all(name):
917 return
918 self.record_name(name)
919 type_str = self.strip_or_import(self.get_type_annotation(obj))
920 output.append(f"{name}: {type_str}")
921
922
923def method_name_sort_key(name: str) -> tuple[int, str]:

Callers 1

generate_moduleMethod · 0.95

Calls 6

strip_or_importMethod · 0.95
get_type_annotationMethod · 0.95
is_private_nameMethod · 0.80
is_not_in_allMethod · 0.80
record_nameMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected