MCPcopy Index your code
hub / github.com/github/copilot-sdk / ensureClassVarImport

Function ensureClassVarImport

scripts/codegen/python.ts:667–679  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

665}
666
667function ensureClassVarImport(code: string): string {
668 // Already imported?
669 if (/\bfrom typing import [^\n]*\bClassVar\b/.test(code)) return code;
670 return code.replace(
671 /^from typing import (.+)$/m,
672 (_match, names) => {
673 const list = names.split(",").map((n: string) => n.trim()).filter(Boolean);
674 list.push("ClassVar");
675 list.sort();
676 return `from typing import ${[...new Set(list)].join(", ")}`;
677 }
678 );
679}
680
681function pushPyExperimentalComment(lines: string[], subject: PyExperimentalSubject, indent = ""): void {
682 lines.push(pyExperimentalComment(subject, indent));

Calls 2

joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…