-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add Typeshare support for Python #169
base: main
Are you sure you want to change the base?
Add Typeshare support for Python #169
Conversation
Thanks to the prior work of @adriangb: 1Password#25
@@ -14,6 +14,9 @@ thiserror = "1" | |||
itertools = "0.12" | |||
lazy_format = "2" | |||
joinery = "2" | |||
topological-sort = { version = "0.2.2"} | |||
once_cell = { version = "1"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the built-in oncelock https://doc.rust-lang.org/std/sync/struct.OnceLock.html
core/src/language/python.rs
Outdated
} | ||
|
||
#[derive(Debug, Clone)] | ||
enum ParsedRusthThing<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: parsedrustthing
core/src/language/python.rs
Outdated
/// Mappings from Rust type names to Python type names | ||
pub type_mappings: HashMap<String, String>, | ||
/// The Python module for the generated code. | ||
pub module: RefCell<Module>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a refcell here?
module.add_global(identifier, vec![id.clone()]) | ||
} | ||
RustType::Simple { id } => module.add_global(identifier, vec![id.clone()]), | ||
RustType::Special(_) => {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type aliases for special types are unsupported?
core/src/language/python.rs
Outdated
| SpecialRustType::I64 | ||
| SpecialRustType::ISize | ||
| SpecialRustType::USize => { | ||
panic!("64 bit types not allowed in Typeshare") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're supported by python, though, so I'm not seeing any reason to fail here.
Doing some review, sorry for the delay. I'd like to ask for a high-level description in this MR for how this integration works, with especial focus on how structs are handled (in particular how the JSON <-> struct boundary is handled). |
f4540ab
to
85634d4
Compare
85634d4
to
48a8adb
Compare
fbfde61
to
5c88f19
Compare
c901b1b
to
9935aaf
Compare
9935aaf
to
a74e4ce
Compare
fixing optional field set to default
Thanks to the prior work of @adriangb: #25
This will be picked up in the coming weeks. Would already appreciate a provisional review with high-level feedback on design!