Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest fails against pydantic 2.5.2 #14

Open
charles-dyfis-net opened this issue Dec 8, 2023 · 6 comments
Open

pytest fails against pydantic 2.5.2 #14

charles-dyfis-net opened this issue Dec 8, 2023 · 6 comments

Comments

@charles-dyfis-net
Copy link

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`.
@charles-dyfis-net
Copy link
Author

Updating pyproject.toml to specify pydantic<2.0 is not ideal, but gets one out of the immediate situation.

@charles-dyfis-net
Copy link
Author

This one still happens against 3.0.4.

@copdips
Copy link

copdips commented Mar 21, 2024

need this, as quart-schema is using pydantic v2

@joeblackwaslike
Copy link
Owner

@charles-dyfis-net I've reviewed your pull request, ping me when you've updated your branch.

@joeblackwaslike
Copy link
Owner

also in general, checkout the diffs on the sim branches, they're an experimental attempt to solve the same problem but from first principals.

@charles-dyfis-net
Copy link
Author

I've migrated away from Quart, so the PR I filed should probably be considered abandoned at this time.

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

No branches or pull requests

3 participants