redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.07k stars 108 forks source link

Allow using Pydantic v2 #533

Closed ninoseki closed 1 year ago

ninoseki commented 1 year ago

The latest version of FastAPI (v0.100.0) supports Pydantic v2.

I'd like to use redis-om-python with Pydantic v2 while keeping the compatibility.

This PR does:

It allows using Pydantic v2 along with redis-om-python.

ninoseki commented 1 year ago

There are lint & dependency audit errors.

I'm sure the lint error is out of the scope of this PR.

/home/runner/.local/bin/poetry run mypy ./tests/ aredis_om redis_om --ignore-missing-imports --exclude _compat\.py$
redis_om/model/cli/migrate.py:6: error: Argument 1 has incompatible type "Callable[[Any], Any]"; expected <nothing>
aredis_om/model/cli/migrate.py:6: error: Argument 1 has incompatible type "Callable[[Any], Any]"; expected <nothing>

I'm not sure about the audit error. Could you help me to fix the issue, please? (If this PR looks good)

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 68.42% and project coverage change: -0.33 :warning:

Comparison is base (70f6401) 78.94% compared to head (099ca96) 78.61%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #533 +/- ## ========================================== - Coverage 78.94% 78.61% -0.33% ========================================== Files 14 15 +1 Lines 1178 1188 +10 ========================================== + Hits 930 934 +4 - Misses 248 254 +6 ``` | Flag | Coverage Δ | | |---|---|---| | unit | `78.61% <68.42%> (-0.33%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/redis/redis-om-python/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis) | Coverage Δ | | |---|---|---| | [aredis\_om/\_compat.py](https://app.codecov.io/gh/redis/redis-om-python/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis#diff-YXJlZGlzX29tL19jb21wYXQucHk=) | `60.00% <60.00%> (ø)` | | | [aredis\_om/model/encoders.py](https://app.codecov.io/gh/redis/redis-om-python/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis#diff-YXJlZGlzX29tL21vZGVsL2VuY29kZXJzLnB5) | `50.70% <100.00%> (-0.69%)` | :arrow_down: | | [aredis\_om/model/model.py](https://app.codecov.io/gh/redis/redis-om-python/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=redis#diff-YXJlZGlzX29tL21vZGVsL21vZGVsLnB5) | `87.03% <100.00%> (-0.06%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

chayim commented 1 year ago

@ninoseki I've merged master in accordingly.

ninoseki commented 1 year ago

Thanks and please let me know if I need additional works on this PR.

chayim commented 1 year ago

given the opt in nature - and the pydantic changes.. it seems very clean.