Skip to content

remove pydantic deprecation warning#219

Merged
himkt merged 1 commit intohimkt:mainfrom
hirosassa:follow-pydantic-update
Apr 29, 2025
Merged

remove pydantic deprecation warning#219
himkt merged 1 commit intohimkt:mainfrom
hirosassa:follow-pydantic-update

Conversation

@hirosassa
Copy link
Contributor

In pytest outputs, there are warnings like below.
I removed two pydantic deprecation warning by replacing dict with model_dump.
ref: https://docs.pydantic.dev/latest/concepts/serialization/#modelmodel_dump

=============================== warnings summary ===============================
tests/api/v1/test_batch_tokenization.py: 10 warnings
  /home/runner/work/konoha/konoha/src/konoha/api/v1/batch_tokenization.py:29: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
    params = params.dict(exclude={"text", "texts"})

tests/api/v1/test_batch_tokenization.py::test_tokenization[tokenizer_params7]
  /home/runner/work/konoha/konoha/.venv/lib/python3.11/site-packages/nagisa/tagger.py:45: DeprecationWarning: invalid escape sequence '\('
    single_word_list = [w.replace('(', '\(').replace(')', '\)')

tests/api/v1/test_batch_tokenization.py::test_tokenization[tokenizer_params7]
  /home/runner/work/konoha/konoha/.venv/lib/python3.11/site-packages/nagisa/tagger.py:45: DeprecationWarning: invalid escape sequence '\)'
    single_word_list = [w.replace('(', '\(').replace(')', '\)')

tests/api/v1/test_tokenization.py: 11 warnings
  /home/runner/work/konoha/konoha/src/konoha/api/v1/tokenization.py:29: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/
    params = params.dict(exclude={"text", "texts"})

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Copy link
Owner

@himkt himkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@himkt himkt merged commit d37daf5 into himkt:main Apr 29, 2025
0 of 4 checks passed
@hirosassa hirosassa deleted the follow-pydantic-update branch April 29, 2025 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants