Skip to content

pytest fails against pydantic 2.5.2 #14

Description

@charles-dyfis-net

With filterwarnings = ["error"] in [tool.pytest.ini_options] in pyproject.toml, running pytest fails with:

$ pytest
ImportError while loading conftest '/Users/chaduffy/dev/quart-sqlalchemy/tests/conftest.py'.
tests/conftest.py:11: in <module>
    from quart_sqlalchemy import SQLAlchemyConfig
src/quart_sqlalchemy/__init__.py:3: in <module>
    from .bind import AsyncBind
src/quart_sqlalchemy/bind.py:16: in <module>
    from .config import BindConfig
src/quart_sqlalchemy/config.py:62: in <module>
    class ConfigBase(BaseModel):
venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py:90: in __new__
    config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs)
venv/lib/python3.11/site-packages/pydantic/_internal/_config.py:120: in for_model
    config_from_namespace = config_dict_from_namespace or prepare_config(config_class_from_namespace)
venv/lib/python3.11/site-packages/pydantic/_internal/_config.py:271: in prepare_config
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)
E   pydantic.warnings.PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/

When not escalating all warnings to errors, we get a separate pydantic error thrown during pytest execution:

ImportError while loading conftest '/Users/chaduffy/dev/quart-sqlalchemy/tests/conftest.py'.
tests/conftest.py:11: in <module>
    from quart_sqlalchemy import SQLAlchemyConfig
src/quart_sqlalchemy/__init__.py:3: in <module>
    from .bind import AsyncBind
src/quart_sqlalchemy/bind.py:16: in <module>
    from .config import BindConfig
src/quart_sqlalchemy/config.py:102: in <module>
    class EngineConfig(ConfigBase):
src/quart_sqlalchemy/config.py:141: in EngineConfig
    @root_validator
venv/lib/python3.11/site-packages/pydantic/deprecated/class_validators.py:231: in root_validator
    return root_validator()(*__args)  # type: ignore
venv/lib/python3.11/site-packages/pydantic/deprecated/class_validators.py:237: in root_validator
    raise PydanticUserError(
E   pydantic.errors.PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions