MCPcopy
hub / github.com/python/mypy / visit_class_def

Method visit_class_def

mypy/strconv.py:174–202  ·  view source on GitHub ↗
(self, o: mypy.nodes.ClassDef)

Source from the content-addressed store, hash-verified

172 return self.dump(a, o)
173
174 def visit_class_def(self, o: mypy.nodes.ClassDef) -> str:
175 a = [o.name, o.defs.body]
176 # Display base types unless they are implicitly just builtins.object
177 # (in this case base_type_exprs is empty).
178 if o.base_type_exprs:
179 if o.info and o.info.bases:
180 if len(o.info.bases) != 1 or o.info.bases[0].type.fullname != "builtins.object":
181 a.insert(1, ("BaseType", o.info.bases))
182 else:
183 a.insert(1, ("BaseTypeExpr", o.base_type_exprs))
184 if o.type_vars:
185 a.insert(1, ("TypeVars", o.type_vars))
186 if o.metaclass:
187 a.insert(1, f"Metaclass({o.metaclass.accept(self)})")
188 if o.keywords:
189 keyword_items = [f"{k}={v.accept(self)}" for k, v in o.keywords.items()]
190 a.insert(1, f"Keywords({', '.join(keyword_items)})")
191 if o.decorators:
192 a.insert(1, ("Decorators", o.decorators))
193 if o.info and o.info._promote:
194 a.insert(1, f"Promote([{','.join(self.stringify_type(p) for p in o.info._promote)}])")
195 if o.info and o.info.tuple_type:
196 a.insert(1, ("TupleType", [o.info.tuple_type]))
197 if o.info and o.info.fallback_to_any:
198 a.insert(1, "FallbackToAny")
199 if o.type_args:
200 for p in reversed(o.type_args):
201 a.insert(1, self.type_param(p))
202 return self.dump(a, o)
203
204 def visit_var(self, o: mypy.nodes.Var) -> str:
205 lst = ""

Callers

nothing calls this directly

Calls 9

stringify_typeMethod · 0.95
type_paramMethod · 0.95
dumpMethod · 0.95
lenFunction · 0.85
reversedFunction · 0.85
insertMethod · 0.80
acceptMethod · 0.45
itemsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected