-
Notifications
You must be signed in to change notification settings - Fork 61
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
Python Generator now creates types = None in classes for all optional types #1165
base: canary
Are you sure you want to change the base?
Conversation
… types This was previously breaking literal? types
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
❌ Changes requested. Reviewed everything up to e467f07 in 53 seconds
More details
- Looked at
579
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_aAbzK8jPiYiviPWn
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
@@ -160,11 +160,11 @@ impl<'ir> From<ClassWalker<'ir>> for PartialPythonClass<'ir> { | |||
} | |||
} | |||
|
|||
pub fn add_default_value(node: &FieldType, type_str: &String) -> String { | |||
if type_str.starts_with("Optional[") { | |||
pub fn add_default_value(node: &FieldType, type_str: String) -> String { |
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.
The change from &String
to String
in the add_default_value
function signature is unnecessary and can lead to unnecessary cloning. Consider reverting to &String
for efficiency.
pub fn add_default_value(node: &FieldType, type_str: String) -> String { | |
pub fn add_default_value(node: &FieldType, type_str: &String) -> String { |
note for the future, we cant merge this since we need default None types or anyone using these models with fastapi or whatnot will get exceptions (fastapi requires default None types for all optionals) |
This was previously breaking literal? types
Important
The PR updates the Python generator to remove default
None
assignments for optional fields, fixing issues with literal types.add_default_value
ingenerate_types.rs
to remove defaultNone
for optional types.None
values.generate_types.rs
: Modifiedadd_default_value
function.partial_types.py
: Removed defaultNone
from optional fields in classes likeBigNumbers
,BinaryNode
, andBlockConstraint
.types.py
: Removed defaultNone
from optional fields in classes likeContactInfo
,CustomTaskResult
, andNested
.None
assignments.This description was created by for e467f07. It will automatically update as commits are pushed.