Skip to content

Commit

Permalink
added None to Optional field
Browse files Browse the repository at this point in the history
  • Loading branch information
amandayu1 committed Aug 22, 2024
1 parent 5c88f19 commit ba24eff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/language/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl Python {
.format_type(&field.ty, generic_types)
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
if field.ty.is_optional() || field.has_default {
python_type = format!("Optional[{}]", python_type);
python_type = format!("Optional[{}] = None", python_type);
self.module
.add_import("typing".to_string(), "Optional".to_string());
}
Expand All @@ -688,7 +688,7 @@ impl Python {
w,
" {}: {} = {}",
python_field_name, python_type, default,
)?,
)?,
None => writeln!(w, " {}: {}", python_field_name, python_type)?,
}

Expand Down

0 comments on commit ba24eff

Please sign in to comment.