Skip to content
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

Upgrade Pydantic Dependency to Pydantic 2 #217

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ab13d5d
Bump pydantic dep to `~=2.0`
QMalcolm Aug 15, 2023
3a4925c
Explicitly set `Optional` pydantic object fields to default to `None`
QMalcolm Aug 15, 2023
77d2d9d
Migrate to `model_dump_json()` from deprecated `json()`
QMalcolm Aug 15, 2023
91e1af3
Migrate to `model_validate()` from deprecated `parse_obj()`
QMalcolm Aug 15, 2023
651c68c
Migrate to `model_validate_json()` from deprecated `parse_raw()`
QMalcolm Aug 15, 2023
5180749
Bump pydantic dep to `~=2.5`
esciara Nov 23, 2023
826bd37
Migrate to `ConfigDict` from deprecated `class Config`
esciara Nov 23, 2023
ae3e729
Migrate to `model_validator` from deprecated `root_validator`
esciara Nov 23, 2023
1e7581c
Migrate to `field_validator` and `model_validator` from deprecated `v…
esciara Nov 24, 2023
6e5ca54
fix test_nested_dataclass
esciara Nov 24, 2023
815da61
fix test_interfaces_version_matches
esciara Nov 24, 2023
84367f3
Migrate to `model_validate()` from deprecated `parse_obj()` in tests
esciara Nov 24, 2023
8a91813
Migrate to `model_dump_json()` from deprecated `json()` in tests
esciara Nov 24, 2023
05a62d8
Migrate to `model_validate_json()` from deprecated `parse_raw()` in t…
esciara Nov 24, 2023
bd92908
Migrate to `model_validator` from deprecated `__get_validators__`
esciara Nov 24, 2023
6dc47c1
Adjusted test to conform to pydantic change of validation behavior (n…
esciara Nov 24, 2023
eb9e5e1
result of `changie new`
esciara Nov 24, 2023
196177d
pydantic dep back to `~=2.0` to avoid unnecessary restriction
esciara Nov 30, 2023
7ac939c
fix following rebase on bump to 0.5.0a2
esciara Dec 8, 2023
aeeadc2
update `changie` file
esciara Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate to ConfigDict from deprecated class Config
  • Loading branch information
esciara committed Dec 8, 2023
commit 826bd37b19147e626c64013e357cde847333ee6f
7 changes: 2 additions & 5 deletions dbt_semantic_interfaces/implementations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from abc import ABC, abstractmethod
from typing import Any, Callable, ClassVar, Generator, Generic, Type, TypeVar

from pydantic import BaseModel, root_validator
from pydantic import BaseModel, ConfigDict, root_validator

from dbt_semantic_interfaces.errors import ParsingException
from dbt_semantic_interfaces.parsing.yaml_loader import (
Expand All @@ -27,10 +27,7 @@ def __hash__(self) -> int: # noqa: D
class FrozenBaseModel(HashableBaseModel):
"""Similar to HashableBaseModel but faux immutable."""

class Config:
"""Pydantic feature."""

allow_mutation = False
model_config = ConfigDict(frozen=True)

def to_pretty_json(self) -> str:
"""Convert to a pretty JSON representation."""
Expand Down
5 changes: 2 additions & 3 deletions dbt_semantic_interfaces/implementations/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Optional

from pydantic import Field
from pydantic import ConfigDict, Field
from typing_extensions import override

from dbt_semantic_interfaces.implementations.base import HashableBaseModel
Expand All @@ -21,8 +21,7 @@ class PydanticExportConfig(HashableBaseModel, ProtocolHint[ExportConfig]):
enables parsing for both `schema` and `schema_name` when deserializing from JSON.
"""

class Config: # noqa: D
allow_population_by_field_name = True
model_config = ConfigDict(populate_by_name=True)

@override
def _implements_protocol(self) -> ExportConfig:
Expand Down
8 changes: 2 additions & 6 deletions dbt_semantic_interfaces/validations/validator_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)

import click
from pydantic import BaseModel, Extra
from pydantic import BaseModel, ConfigDict

from dbt_semantic_interfaces.implementations.base import FrozenBaseModel
from dbt_semantic_interfaces.protocols import Metadata, SemanticManifestT, SemanticModel
Expand Down Expand Up @@ -72,11 +72,7 @@ class FileContext(BaseModel):

file_name: Optional[str] = None
line_number: Optional[int] = None

class Config:
"""Pydantic class configuration options."""

extra = Extra.forbid
model_config = ConfigDict(extra="forbid")

def context_str(self) -> str:
"""Human-readable stringified representation of the context."""
Expand Down