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

Function unwrapRedundantPythonLambdas

scripts/codegen/python.ts:856–861  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

854 * This keeps the generated Python readable and avoids CodeQL "unnecessary lambda" findings.
855 */
856function 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
863function 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;

Callers 2

generateRpcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…