Skip to content

Commit

Permalink
something about pyright/pydantic changed
Browse files Browse the repository at this point in the history
This is now the recommended way to set default values. Doing it the
previous way causes pyright to assuming you're accidentally omitting
required values. Doing it this way is somehow able to tell pyright that
these fields are actually optional/have defaults and do not need to be
specified. See [here][0] for details. Change seems to have been
introduced by [this][1].

[0]: pydantic/pydantic#3753 (comment)

[1]: pydantic/pydantic#2721
  • Loading branch information
CobaltCause committed May 19, 2022
1 parent 1a566bc commit 32caff7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/codegen/types.rs
Expand Up @@ -48,9 +48,9 @@ pub fn types(openapi: &OpenApi) -> String {
code.push_str(&type_to_string(&data.r#type, true));

if matches!(data.r#type, Type::Option(_)) {
code.push_str(" = Field(None, ");
code.push_str(" = Field(default=None, ");
} else {
code.push_str(" = Field(..., ");
code.push_str(" = Field(default=..., ");
}

// Pydantic field documentation
Expand Down

0 comments on commit 32caff7

Please sign in to comment.