-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update model fields for consistent usage of Optional
and default
#6829
Conversation
✅ Deploy Preview for prefect-orion ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
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.
Looks good! I was a bit cross-eyed by the end, but all I found a couple places where Optional
didn't need to be imported.
Co-authored-by: Chris Pickett <chris.pickett@prefect.io>
Thanks! Yeah I got to a point where I'd made all these changes and then everything was failing because |
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.
This makes a lot of sense to me, and the only change we might need to check in on with Prefect Cloud is the ORMBaseModel
. I'm not expecting any trouble, what you've done here is totally compatible and just making the implicit explicit (thank you!)
Makes two readability and consistency changes to our models:
Optional
for types when field defaults areNone
None
default=
explicitlyBaseSettings - pylance complains for not setting default values to fields pydantic/pydantic#3753
https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md#field-descriptors
There should be no change in behavior here. This was performed with some crazy regular expressions then manual edits for edge cases. Please give it a second look.
The lack of explicit
Optional
types lead to issues in #6813 — this change should unblock that.Example
The following:
has changed to:
Checklist
<link to issue>
"fix
,feature
,enhancement
,docs
,collections
, ormaintenance
label categorizing the change.