Skip to content

Commit

Permalink
feat: bump pydantic version to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HLasse committed Feb 6, 2024
1 parent b23beb2 commit ce91e56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies = [
"pandas>=1.0.0",
"pyphen>=0.11.0,<0.15.0",
"ftfy>=6.0.3,<6.1.0",
"pydantic>=2.0",
]

requires-python = ">=3.8"
Expand Down
14 changes: 4 additions & 10 deletions src/textdescriptives/components/quality_data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Dict, Optional, Tuple, Union

from pydantic import BaseModel, Extra, Field
from pydantic import ConfigDict, BaseModel, Field

Interval = Tuple[Optional[float], Optional[float]]

Expand All @@ -20,9 +20,7 @@ class ThresholdsOutput(BaseModel):
>>> t_out.passed
True
"""

class Config:
extra = Extra.forbid
model_config = ConfigDict(extra="forbid")

threshold: Union[Interval, bool, None]
value: Union[float, None]
Expand Down Expand Up @@ -60,9 +58,7 @@ def __eq__(self, other: Any) -> bool:

class QualityThresholds(BaseModel):
"""Thresholds for quality metrics."""

class Config:
extra = Extra.forbid
model_config = ConfigDict(extra="forbid")

n_stop_words: Interval = Field(
(2, None),
Expand Down Expand Up @@ -163,9 +159,7 @@ class Config:

class QualityOutput(BaseModel):
"""The output of the quality function."""

class Config:
extra = Extra.forbid
model_config = ConfigDict(extra="forbid")

n_stop_words: ThresholdsOutput = Field(
...,
Expand Down

0 comments on commit ce91e56

Please sign in to comment.