diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1871aa71..c87332bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: - name: Python Semantic Release id: release - uses: python-semantic-release/python-semantic-release@v8.0.4 + uses: python-semantic-release/python-semantic-release@v9.4.1 with: github_token: ${{ secrets.RELEASE }} root_options: "-vv" diff --git a/docs/tutorials/requirements.txt b/docs/tutorials/requirements.txt index 8a232dc3..acebe206 100644 --- a/docs/tutorials/requirements.txt +++ b/docs/tutorials/requirements.txt @@ -2,4 +2,4 @@ # e.g. links to wheels which is not allowed in pyproject.toml on pypi # spacy pipeline -https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.4.0/en_core_web_sm-3.4.0.tar.gz +https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.6.0/en_core_web_sm-3.6.0.tar.gz diff --git a/pyproject.toml b/pyproject.toml index 18ec1760..d01194fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,12 +34,12 @@ keywords = [ ] dependencies = [ - "spacy[lookups]>=3.1.0", + "spacy[lookups]>=3.6.0", "numpy>=1.20.0", "pandas>=1.0.0", "pyphen>=0.11.0,<0.15.0", "ftfy>=6.0.3,<6.1.0", - "pydantic<2.0.0", + "pydantic>=2.0", ] requires-python = ">=3.8" @@ -53,13 +53,14 @@ documentation = "https://hlasse.github.io/TextDescriptives/" style = ["black==24.1.1", "pre-commit==3.6.0", "ruff==0.1.15", "mypy==1.8.0"] tests = ["pytest>=7.1.3", "pytest-cov>=3.0.0"] docs = [ + "pydantic==2.1", "sphinx>=5.3.0", "furo==2022.12.7", "sphinx-copybutton>=0.5.1", "sphinxext-opengraph>=0.7.3", "myst-nb>=0.6.0", "sphinx_design>=0.3.0", - "autodoc_pydantic==1.9.0", + "autodoc_pydantic==2.1.0", ] tutorials = [ "jupyter", diff --git a/src/textdescriptives/components/quality.py b/src/textdescriptives/components/quality.py index 368f347d..adea7113 100644 --- a/src/textdescriptives/components/quality.py +++ b/src/textdescriptives/components/quality.py @@ -514,7 +514,7 @@ def set_quality(self, doc: Doc) -> None: # to allow the variable to json serializable we convert it to json # it is then converted back into a quality output object in the getter - doc._._quality = self.quality_setter(doc).dict() + doc._._quality = self.quality_setter(doc).model_dump() doc._.passed_quality_check = self.passed_quality_thresholds(doc) def passed_quality_thresholds(self, span: Union[Span, Doc]) -> bool: diff --git a/src/textdescriptives/components/quality_data_classes.py b/src/textdescriptives/components/quality_data_classes.py index b8251d70..e730b5be 100644 --- a/src/textdescriptives/components/quality_data_classes.py +++ b/src/textdescriptives/components/quality_data_classes.py @@ -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]] @@ -21,8 +21,7 @@ class ThresholdsOutput(BaseModel): True """ - class Config: - extra = Extra.forbid + model_config = ConfigDict(extra="forbid") threshold: Union[Interval, bool, None] value: Union[float, None] @@ -61,8 +60,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), @@ -164,8 +162,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( ..., diff --git a/tests/requirements.txt b/tests/requirements.txt index bd81a13a..cbce7ed7 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,5 +2,5 @@ # e.g. links to wheels which is not allowed in pyproject.toml on pypi # spacy pipelines -https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz -https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.5.0/en_core_web_md-3.5.0.tar.gz \ No newline at end of file +https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.6.0/en_core_web_sm-3.6.0.tar.gz +https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.6.0/en_core_web_md-3.6.0.tar.gz \ No newline at end of file diff --git a/tests/test_quality.py b/tests/test_quality.py index 6b631822..53d7854a 100644 --- a/tests/test_quality.py +++ b/tests/test_quality.py @@ -4,7 +4,6 @@ import pytest import spacy - import textdescriptives as td from textdescriptives.components.quality import ( alpha_ratio, @@ -208,7 +207,7 @@ def test_quality_component_with_config(nlp: spacy.Language): proportion_bullet_points=(None, 0.8), duplicate_line_chr_fraction=(None, 0.2), duplicate_paragraph_chr_fraction=(None, 0.2), - top_ngram_chr_fraction={2: (None, 0.6), 3: (None, 0.6)}, + top_ngram_chr_fraction={"2": (None, 0.6), "3": (None, 0.6)}, duplicate_ngram_chr_fraction={}, contains={"lorem ipsum": False}, oov_ratio=(None, 0.3),