Skip to content

Commit

Permalink
special serialization rules for 'type' in Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcphers committed Apr 2, 2024
1 parent 50b92a9 commit 453092e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions positron/comms/generate-comms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 453092e

Please sign in to comment.