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

Function appendPythonRpcAllList

scripts/codegen/python.ts:3323–3348  ·  view source on GitHub ↗

* Appends an `__all__` list to the generated RPC module so that the public * ``copilot.rpc`` shim can ``from .generated.rpc import *`` without leaking * helper functions (``from_str``, ``from_int``, …) or TypeVars * (``T``, ``EnumT``). * * Shared types pulled in from session-events (via ``from

(code: string, _definitions: { definitions: Record<string, unknown>; $defs: Record<string, unknown> })

Source from the content-addressed store, hash-verified

3321 * ``GitHub.Copilot.Rpc`` by fully-qualified name.
3322 */
3323function appendPythonRpcAllList(code: string, _definitions: { definitions: Record<string, unknown>; $defs: Record<string, unknown> }): string {
3324 const exported = new Set<string>();
3325
3326 const classPattern = /^class\s+([A-Za-z_]\w*)\b/gm;
3327 let m: RegExpExecArray | null;
3328 while ((m = classPattern.exec(code)) !== null) {
3329 const name = m[1];
3330 if (name.startsWith("_")) continue;
3331 exported.add(name);
3332 }
3333
3334 const assignPattern = /^([A-Z][A-Za-z0-9_]*)\s*=/gm;
3335 while ((m = assignPattern.exec(code)) !== null) {
3336 const name = m[1];
3337 if (name === "T" || name === "EnumT") continue;
3338 exported.add(name);
3339 }
3340
3341 for (const helper of ["rpc_from_dict", "rpc_to_dict"]) {
3342 if (new RegExp(`^def\\s+${helper}\\b`, "m").test(code)) {
3343 exported.add(helper);
3344 }
3345 }
3346
3347 return code.replace(/\s*$/, "") + "\n\n" + renderPythonAllList([...exported].sort()) + "\n";
3348}
3349
3350function renderPythonAllList(names: string[]): string {
3351 const lines: string[] = ["__all__ = ["];

Callers 1

generateRpcFunction · 0.85

Calls 3

renderPythonAllListFunction · 0.85
execMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…