MCPcopy Index your code
hub / github.com/RustPython/RustPython / define_class

Method define_class

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

Source from the content-addressed store, hash-verified

971
972 def test_stringized_annotation_permutations(self):
973 def define_class(name, has_future, has_annos, base_text, extra_names=None):
974 lines = []
975 if has_future:
976 lines.append("from __future__ import annotations")
977 lines.append(f"class {name}({base_text}):")
978 if has_annos:
979 lines.append(f" {name}_attr: int")
980 else:
981 lines.append(" pass")
982 code = "\n".join(lines)
983 ns = support.run_code(code, extra_names=extra_names)
984 return ns[name]
985
986 def check_annotations(cls, has_future, has_annos):
987 if has_annos:

Callers

nothing calls this directly

Calls 3

run_codeMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected