MCPcopy Index your code
hub / github.com/python/cpython / define_class

Method define_class

Lib/test/test_annotationlib.py:998–1009  ·  view source on GitHub ↗
(name, has_future, has_annos, base_text, extra_names=None)

Source from the content-addressed store, hash-verified

996
997 def test_stringized_annotation_permutations(self):
998 def define_class(name, has_future, has_annos, base_text, extra_names=None):
999 lines = []
1000 if has_future:
1001 lines.append("from __future__ import annotations")
1002 lines.append(f"class {name}({base_text}):")
1003 if has_annos:
1004 lines.append(f" {name}_attr: int")
1005 else:
1006 lines.append(" pass")
1007 code = "\n".join(lines)
1008 ns = support.run_code(code, extra_names=extra_names)
1009 return ns[name]
1010
1011 def check_annotations(cls, has_future, has_annos):
1012 if has_annos:

Callers

nothing calls this directly

Calls 3

appendMethod · 0.45
joinMethod · 0.45
run_codeMethod · 0.45

Tested by

no test coverage detected