-
Couldn't load subscription status.
- Fork 3.2k
chore: Remove Pydantic V1 deprecation warnings #15057
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
base: master
Are you sure you want to change the base?
Conversation
| schema_pattern: Optional[AllowDenyPattern] = values.get("schema_pattern") | ||
| @model_validator(mode="after") | ||
| def check_database_is_set(self) -> "RedshiftConfig": | ||
| assert self.database, "database must be set" |
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.
Dangerous use of assert - low severity
When running Python in production in optimized mode, assert calls are not executed. This mode is enabled by setting the PYTHONOPTIMIZE command line flag. Optimized mode is usually ON in production. Any safety check done using assert will not be executed.
Remediation: Raise an exception instead of using assert.
View details in Aikido Security
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
🔴 Meticulous spotted visual differences in 2 of 1093 screens tested: view and approve differences detected. Meticulous evaluated ~8 hours of user flows against your PR. Last updated for commit 6d0d821. This comment will update as new commits are pushed. |
…datahub into chore-pydantic-warnings
…datahub into chore-pydantic-warnings
| assert abs(delta) >= get_bucket_duration_delta(bucket_duration), ( | ||
| "Relative start time should be in terms of configured bucket duration. e.g '-2 days' or '-2 hours'." | ||
| ) |
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.
Dangerous use of assert - low severity
When running Python in production in optimized mode, assert calls are not executed. This mode is enabled by setting the PYTHONOPTIMIZE command line flag. Optimized mode is usually ON in production. Any safety check done using assert will not be executed.
Remediation: Raise an exception instead of using assert.
View details in Aikido Security
| assert max_num_fields_to_profile is None, ( | ||
| f"{max_num_fields_to_profile_key} should be set to None" | ||
| "max_number_of_fields_to_profile should be set to None" | ||
| ) |
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.
Dangerous use of assert - low severity
When running Python in production in optimized mode, assert calls are not executed. This mode is enabled by setting the PYTHONOPTIMIZE command line flag. Optimized mode is usually ON in production. Any safety check done using assert will not be executed.
Remediation: Raise an exception instead of using assert.
View details in Aikido Security
| assert max_num_fields_to_profile is None, ( | ||
| f"{max_num_fields_to_profile_key} should be set to None" | ||
| "max_number_of_fields_to_profile should be set to None" | ||
| ) |
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.
Dangerous use of assert - low severity
When running Python in production in optimized mode, assert calls are not executed. This mode is enabled by setting the PYTHONOPTIMIZE command line flag. Optimized mode is usually ON in production. Any safety check done using assert will not be executed.
Remediation: Raise an exception instead of using assert.
View details in Aikido Security
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.
nice!
| raise ValueError(f"Output port {v} is not an urn: {e}") from e | ||
| @field_validator("assets") | ||
| @classmethod | ||
| def assets_must_be_urns(cls, v): |
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.
Missing type hints for params and return types, similar with output_ports_must_be_urns
| raise ValueError(f"Output port {v} is not in asset list") | ||
| return v | ||
| @model_validator(mode="after") | ||
| def output_ports_must_be_from_asset_list(self): |
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.
We should name the validator for better error messaging
| raise ValueError(f"asset {v} is not an urn: {e}") from e | ||
| return v | ||
|
|
||
| @field_validator("output_ports") |
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.
each_item is deprecated -> the migration doc takes about Annotated metadata for better Type reuse. Not sure if we could apply here: https://docs.pydantic.dev/latest/migration/#changes-to-validators
| return full_name | ||
| else: | ||
| return v | ||
| @model_validator(mode="after") |
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.
always=True -> Field(validate_default=True) as per the migration doc https://docs.pydantic.dev/latest/migration/#changes-to-validators
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.
LGTM! Left some minor comments
Migrate deprecated Pydantic V1 patterns to V2:
@validator→@field_validator@root_validator→@model_validator.dict()→.model_dump()Banned APIs to prevent those APIs being used again.