From 453092ee7775a90b530e049802cf7529d6078101 Mon Sep 17 00:00:00 2001 From: Jonathan McPherson Date: Mon, 1 Apr 2024 17:28:06 -0700 Subject: [PATCH] special serialization rules for 'type' in Rust --- positron/comms/generate-comms.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/positron/comms/generate-comms.ts b/positron/comms/generate-comms.ts index fda728e4683..f06dfe97910 100644 --- a/positron/comms/generate-comms.ts +++ b/positron/comms/generate-comms.ts @@ -438,7 +438,12 @@ use serde::Serialize; if (prop.description) { yield formatComment('\t/// ', prop.description); } - yield `\tpub ${key}: `; + if (key === 'type') { + yield '\t#[serde(rename = "type")]\n'; + yield `\tpub ${name}_type: `; + } else { + yield `\tpub ${key}: `; + } if (!o.required || !o.required.includes(key)) { yield 'Option<'; yield deriveType(contracts, RustTypeMap, [key, ...context], prop); @@ -1345,7 +1350,7 @@ async function createCommInterface() { // Use black to format the Python file; the lint tests for the // Python extension require that the Python files have exactly the // format that black produces. - execSync(`python -m black ${pythonOutputFile}`, { stdio: 'ignore' }); + execSync(`python3 -m black ${pythonOutputFile}`, { stdio: 'ignore' }); } } catch (e: any) { if (e.message) {