* Collapse lambdas that only forward their single argument into another callable. * This keeps the generated Python readable and avoids CodeQL "unnecessary lambda" findings.
(code: string)
| 854 | * This keeps the generated Python readable and avoids CodeQL "unnecessary lambda" findings. |
| 855 | */ |
| 856 | function unwrapRedundantPythonLambdas(code: string): string { |
| 857 | return code.replace( |
| 858 | /lambda\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*((?:[A-Za-z_][A-Za-z0-9_]*)(?:\.[A-Za-z_][A-Za-z0-9_]*)*)\(\1\)/g, |
| 859 | "$2" |
| 860 | ); |
| 861 | } |
| 862 | |
| 863 | function collapsePlaceholderPythonDataclasses(code: string, knownDefinitionNames?: Set<string>): string { |
| 864 | const classBlockRe = /(@dataclass\r?\nclass\s+(\w+):[\s\S]*?)(?=^@dataclass|^class\s+\w+|^def\s+\w+|\Z)/gm; |
no outgoing calls
no test coverage detected
searching dependent graphs…