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

💚 Fix linting in CI #1340

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

💚 Fix linting in CI #1340

wants to merge 6 commits into from

Conversation

svlandeg
Copy link
Member

@svlandeg svlandeg commented Apr 9, 2025

Recent PRs have been failing due to an issue with the linting step in the CI - I think caused by the recent release of Pydantic 2.11.

Overview of issues and proposed fixes:

  • Elaborate type warning for get_model_fields in _compat.py.
sqlmodel/_compat.py:106: error: Argument 1 to "__get__" of "deprecated_instance_property" has incompatible type "BaseModel | type[BaseModel]"; expected "BaseModel"  [arg-type]
sqlmodel/_compat.py:106: error: Argument 2 to "__get__" of "deprecated_instance_property" has incompatible type "type[BaseModel] | type[type[BaseModel]]"; expected "type[BaseModel]"  [arg-type]

I think it's fine to ignore this one?

  • model_fields in SQLModelMetaclass on the other hand, now can do without an ignore warning
  • SQLModel.model_validate() is supposed to overwrite BaseModel.model_validate() but an error gets raised because of the update input parameter, which is not present in BaseModel.model_validate(). The proposed solution here is to work via **kwargs, which I'm generally not a fan of, but the only other option I would see is adding yet another ignore, which feels wrong in this case.
  • SQLModel.model_dump() is supposed to overwrite BaseModel.model_dump() but an error gets raised because of context and alias having a wrong type, and fallback not being present. fallback was introduced in Pydantic v2.11. So instead of restricting Pydantic, I suggest to (again) work via **kwargs.

The linting test is failing for Python 3.8 in different ways than for all other Python versions, probably because Python 3.8 support was removed for Pydantic 2.11. Accordingly, I've updated the test.yml to skip the linting test for Python 3.8. This doesn't feel like a clean solution either, and I guess the other option is to (also) drop support for Python 3.8.

@svlandeg svlandeg self-assigned this Apr 9, 2025
@svlandeg svlandeg removed their assignment Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants