Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special serialization rules for 'type' in Rust #2598

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches python3 usage elsewhere in this file and fixes an issue on recent macOS which has no Python on the $PATH.

}
} catch (e: any) {
if (e.message) {
Expand Down
Loading