(code: string)
| 665 | } |
| 666 | |
| 667 | function 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 | |
| 681 | function pushPyExperimentalComment(lines: string[], subject: PyExperimentalSubject, indent = ""): void { |
| 682 | lines.push(pyExperimentalComment(subject, indent)); |
no test coverage detected
searching dependent graphs…