Skip to content

Commit

Permalink
chore: remove pydantic.v1 import (#364)
Browse files Browse the repository at this point in the history
Use correct Field (v2) from pydantic. Symptom was that json-schema did
not use alias when generating schema.
  • Loading branch information
jsolaas authored and equinor-schen committed Aug 23, 2024
1 parent a6c205e commit 886b639
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 116 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lib-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Install deps
run: poetry install --no-interaction

- name: List pydantic version
run: poetry show pydantic

- name: Run tests with coverage
run: poetry run python -m coverage run -m pytest -n auto

Expand Down
4 changes: 3 additions & 1 deletion src/libecalc/presentation/yaml/yaml_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@


class YamlBase(BaseModel, ABC):
model_config = ConfigDict(populate_by_name=True, alias_generator=str.upper, extra="forbid")
model_config = ConfigDict(
populate_by_name=True, alias_generator=lambda field_name: field_name.upper(), extra="forbid"
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from typing import List

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types import YamlBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from typing import Literal

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types.components.legacy.energy_usage_model.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from typing import List, Literal

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types import YamlBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from typing import List, Literal

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types.components.legacy.energy_usage_model.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import enum
from typing import Literal

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types.components.legacy.energy_usage_model.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from typing import Literal

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types.components.legacy.energy_usage_model.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from typing import List, Literal

try:
from pydantic.v1 import Field
except ImportError:
from pydantic import Field
from pydantic import Field

from libecalc.expression.expression import ExpressionType
from libecalc.presentation.yaml.yaml_types import YamlBase
Expand Down

Large diffs are not rendered by default.

0 comments on commit 886b639

Please sign in to comment.