From b12b432439e204ebabbbe2c32d8e60ca77fdf7a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:19:29 +0300 Subject: [PATCH 01/10] Bump rojopolis/spellcheck-github-actions from 0.29.0 to 0.33.0 (#526) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chayim --- .github/workflows/spellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index ff5b50e..03534b4 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -8,7 +8,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Check Spelling - uses: rojopolis/spellcheck-github-actions@0.29.0 + uses: rojopolis/spellcheck-github-actions@0.33.0 with: config_path: .github/spellcheck-settings.yml task_name: Markdown From c43076a405b4030a4c498ab9931284a20723e2eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:33:52 +0300 Subject: [PATCH 02/10] Update email-validator requirement from ^1.3.0 to ^2.0.0 (#501) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chayim --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 52bb4dd..c84e05a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ pytest-cov = "^4.0.0" pytest-xdist = "^3.1.0" unasync = "^0.5.0" pytest-asyncio = "^0.20.3" -email-validator = "^1.3.0" +email-validator = "^2.0.0" tox = "^3.26.0" tox-pyenv = "^1.1.0" From 323787151e4c628d1a1101ddc353aae369c9a3eb Mon Sep 17 00:00:00 2001 From: Chayim Date: Wed, 12 Jul 2023 11:39:50 +0300 Subject: [PATCH 03/10] Updating README badges (#537) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe643fc..28e9618 100644 --- a/README.md +++ b/README.md @@ -386,8 +386,8 @@ Redis OM uses the [MIT license][license-url]. [version-svg]: https://img.shields.io/pypi/v/redis-om?style=flat-square [package-url]: https://pypi.org/project/redis-om/ -[ci-svg]: https://img.shields.io/github/workflow/status/redis/redis-om-python/CI?style=flat-square -[ci-url]: https://github.com/redis/redis-om-python/actions/workflows/CI.yml +[ci-svg]: https://img.shields.io/github/workflow/status/redis/redis-om-python/ci?style=flat-square +[ci-url]: https://github.com/redis/redis-om-python/actions/workflows/ci.yml [license-image]: https://img.shields.io/badge/license-mit-green.svg?style=flat-square [license-url]: LICENSE From 3a0fa0c7bee40e26dc205a333918d74fbbec299a Mon Sep 17 00:00:00 2001 From: Manabu Niseki Date: Wed, 12 Jul 2023 17:48:08 +0900 Subject: [PATCH 04/10] Allow using Pydantic v2 (#533) Co-authored-by: Chayim --- Makefile | 2 +- aredis_om/_compat.py | 19 +++++++++++++++++++ aredis_om/model/encoders.py | 3 +-- aredis_om/model/model.py | 18 ++++++++++++------ pyproject.toml | 2 +- tests/_compat.py | 7 +++++++ tests/test_hash_model.py | 2 +- tests/test_json_model.py | 2 +- tests/test_oss_redis_features.py | 2 +- tests/test_pydantic_integrations.py | 2 +- 10 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 aredis_om/_compat.py create mode 100644 tests/_compat.py diff --git a/Makefile b/Makefile index 11ae817..f478ead 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ lint: $(INSTALL_STAMP) dist $(POETRY) run isort --profile=black --lines-after-imports=2 ./tests/ $(NAME) $(SYNC_NAME) $(POETRY) run black ./tests/ $(NAME) $(POETRY) run flake8 --ignore=W503,E501,F401,E731 ./tests/ $(NAME) $(SYNC_NAME) - $(POETRY) run mypy ./tests/ $(NAME) $(SYNC_NAME) --ignore-missing-imports --exclude migrate.py + $(POETRY) run mypy ./tests/ $(NAME) $(SYNC_NAME) --ignore-missing-imports --exclude migrate.py --exclude _compat\.py$ $(POETRY) run bandit -r $(NAME) $(SYNC_NAME) -s B608 .PHONY: format diff --git a/aredis_om/_compat.py b/aredis_om/_compat.py new file mode 100644 index 0000000..0246e4f --- /dev/null +++ b/aredis_om/_compat.py @@ -0,0 +1,19 @@ +from pydantic.version import VERSION as PYDANTIC_VERSION + + +PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.") + +if PYDANTIC_V2: + from pydantic.v1 import BaseModel, validator + from pydantic.v1.fields import FieldInfo, ModelField, Undefined, UndefinedType + from pydantic.v1.json import ENCODERS_BY_TYPE + from pydantic.v1.main import ModelMetaclass, validate_model + from pydantic.v1.typing import NoArgAnyCallable + from pydantic.v1.utils import Representation +else: + from pydantic import BaseModel, validator + from pydantic.fields import FieldInfo, ModelField, Undefined, UndefinedType + from pydantic.json import ENCODERS_BY_TYPE + from pydantic.main import ModelMetaclass, validate_model + from pydantic.typing import NoArgAnyCallable + from pydantic.utils import Representation diff --git a/aredis_om/model/encoders.py b/aredis_om/model/encoders.py index 4007640..2f90e48 100644 --- a/aredis_om/model/encoders.py +++ b/aredis_om/model/encoders.py @@ -31,8 +31,7 @@ from pathlib import PurePath from types import GeneratorType from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union -from pydantic import BaseModel -from pydantic.json import ENCODERS_BY_TYPE +from .._compat import ENCODERS_BY_TYPE, BaseModel SetIntStr = Set[Union[int, str]] diff --git a/aredis_om/model/model.py b/aredis_om/model/model.py index 0ccc5b0..a4c6b9e 100644 --- a/aredis_om/model/model.py +++ b/aredis_om/model/model.py @@ -25,18 +25,24 @@ from typing import ( ) from more_itertools import ichunked -from pydantic import BaseModel, validator -from pydantic.fields import FieldInfo as PydanticFieldInfo -from pydantic.fields import ModelField, Undefined, UndefinedType -from pydantic.main import ModelMetaclass, validate_model -from pydantic.typing import NoArgAnyCallable -from pydantic.utils import Representation from redis.commands.json.path import Path from redis.exceptions import ResponseError from typing_extensions import Protocol, get_args, get_origin from ulid import ULID from .. import redis +from .._compat import BaseModel +from .._compat import FieldInfo as PydanticFieldInfo +from .._compat import ( + ModelField, + ModelMetaclass, + NoArgAnyCallable, + Representation, + Undefined, + UndefinedType, + validate_model, + validator, +) from ..checks import has_redis_json, has_redisearch from ..connections import get_redis_connection from ..util import ASYNC_MODE diff --git a/pyproject.toml b/pyproject.toml index c84e05a..cd774be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ include=[ [tool.poetry.dependencies] python = ">=3.7,<4.0" redis = ">=3.5.3,<5.0.0" -pydantic = "^1.10.2" +pydantic = ">=1.10.2,<2.1.0" click = "^8.0.1" types-redis = ">=3.5.9,<5.0.0" python-ulid = "^1.0.3" diff --git a/tests/_compat.py b/tests/_compat.py new file mode 100644 index 0000000..c21b47d --- /dev/null +++ b/tests/_compat.py @@ -0,0 +1,7 @@ +from aredis_om._compat import PYDANTIC_V2 + + +if PYDANTIC_V2: + from pydantic.v1 import EmailStr, ValidationError +else: + from pydantic import EmailStr, ValidationError diff --git a/tests/test_hash_model.py b/tests/test_hash_model.py index 8fe4a60..38ca18e 100644 --- a/tests/test_hash_model.py +++ b/tests/test_hash_model.py @@ -10,7 +10,6 @@ from unittest import mock import pytest import pytest_asyncio -from pydantic import ValidationError from aredis_om import ( Field, @@ -24,6 +23,7 @@ from aredis_om import ( # We need to run this check as sync code (during tests) even in async mode # because we call it in the top-level module scope. from redis_om import has_redisearch +from tests._compat import ValidationError from .conftest import py_test_mark_asyncio diff --git a/tests/test_json_model.py b/tests/test_json_model.py index ee220bd..8fec6c0 100644 --- a/tests/test_json_model.py +++ b/tests/test_json_model.py @@ -10,7 +10,6 @@ from unittest import mock import pytest import pytest_asyncio -from pydantic import ValidationError from aredis_om import ( EmbeddedJsonModel, @@ -25,6 +24,7 @@ from aredis_om import ( # We need to run this check as sync code (during tests) even in async mode # because we call it in the top-level module scope. from redis_om import has_redis_json +from tests._compat import ValidationError from .conftest import py_test_mark_asyncio diff --git a/tests/test_oss_redis_features.py b/tests/test_oss_redis_features.py index e14f955..4d5b091 100644 --- a/tests/test_oss_redis_features.py +++ b/tests/test_oss_redis_features.py @@ -6,9 +6,9 @@ from typing import Optional import pytest import pytest_asyncio -from pydantic import ValidationError from aredis_om import HashModel, Migrator, NotFoundError, RedisModelError +from tests._compat import ValidationError from .conftest import py_test_mark_asyncio diff --git a/tests/test_pydantic_integrations.py b/tests/test_pydantic_integrations.py index 5ff735f..12d41a9 100644 --- a/tests/test_pydantic_integrations.py +++ b/tests/test_pydantic_integrations.py @@ -4,9 +4,9 @@ from collections import namedtuple import pytest import pytest_asyncio -from pydantic import EmailStr, ValidationError from aredis_om import Field, HashModel, Migrator +from tests._compat import EmailStr, ValidationError today = datetime.date.today() From 3086c2c34bb47ce35962725563b035510d140e10 Mon Sep 17 00:00:00 2001 From: Chayim Date: Wed, 12 Jul 2023 11:48:46 +0300 Subject: [PATCH 05/10] Version 0.2.0 (#536) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cd774be..2004801 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "redis-om" -version = "0.1.3" +version = "0.2.0" description = "Object mappings, and more, for Redis." authors = ["Redis OSS "] maintainers = ["Redis OSS "] From d1f6959be3e7c19c544c769acca29312cb977504 Mon Sep 17 00:00:00 2001 From: Chayim Date: Wed, 12 Jul 2023 13:27:57 +0300 Subject: [PATCH 06/10] Updating the badge, again (#538) badge update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28e9618..cf520f9 100644 --- a/README.md +++ b/README.md @@ -386,7 +386,7 @@ Redis OM uses the [MIT license][license-url]. [version-svg]: https://img.shields.io/pypi/v/redis-om?style=flat-square [package-url]: https://pypi.org/project/redis-om/ -[ci-svg]: https://img.shields.io/github/workflow/status/redis/redis-om-python/ci?style=flat-square +[ci-svg]: https://github.com/redis/redis-om-python/actions/workflows/ci.yml/badge.svg [ci-url]: https://github.com/redis/redis-om-python/actions/workflows/ci.yml [license-image]: https://img.shields.io/badge/license-mit-green.svg?style=flat-square [license-url]: LICENSE From 24427ee502e47fe7c04b661ef477fb7910f52166 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 17:30:57 +0300 Subject: [PATCH 07/10] Bump rojopolis/spellcheck-github-actions from 0.33.0 to 0.33.1 (#540) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/spellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index 03534b4..e152841 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -8,7 +8,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Check Spelling - uses: rojopolis/spellcheck-github-actions@0.33.0 + uses: rojopolis/spellcheck-github-actions@0.33.1 with: config_path: .github/spellcheck-settings.yml task_name: Markdown From c91201f4de8fda27b8a8b585435e46e43391c674 Mon Sep 17 00:00:00 2001 From: Chayim Date: Tue, 18 Jul 2023 17:50:38 +0300 Subject: [PATCH 08/10] Version 0.2.1 (#541) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2004801..a9973b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "redis-om" -version = "0.2.0" +version = "0.2.1" description = "Object mappings, and more, for Redis." authors = ["Redis OSS "] maintainers = ["Redis OSS "] From 1213ca7373ba4f1347a5298e7f6f63cb09949ad2 Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Wed, 6 Sep 2023 14:16:36 +0200 Subject: [PATCH 09/10] Drop Python 3.7 support (#559) --- .github/workflows/ci.yml | 2 +- docs/getting_started.md | 6 +++--- pyproject.toml | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6103d3f..d67f57e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - pyver: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.8", "pypy-3.9" ] + pyver: [ "3.8", "3.9", "3.10", "3.11", "pypy-3.8", "pypy-3.9" ] redisstack: [ "latest" ] fail-fast: false services: diff --git a/docs/getting_started.md b/docs/getting_started.md index c9ada5d..a2d6ff1 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -6,15 +6,15 @@ This tutorial will walk you through installing Redis OM, creating your first mod ## Prerequisites -Redis OM requires Python version 3.7 or above and a Redis instance to connect to. +Redis OM requires Python version 3.8 or above and a Redis instance to connect to. ## Python -Make sure you are running **Python version 3.7 or higher**: +Make sure you are running **Python version 3.8 or higher**: ``` python --version -Python 3.7.0 +Python 3.8.0 ``` If you don't have Python installed, you can download it from [Python.org](https://www.python.org/downloads/), use [pyenv](https://github.com/pyenv/pyenv), or install Python with your operating system's package manager. diff --git a/pyproject.toml b/pyproject.toml index a9973b3..54d3b27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,6 @@ classifiers = [ "Operating System :: OS Independent", "Topic :: Database", 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -35,7 +34,7 @@ include=[ "Issue tracker" = "https://github.com/redis/redis-om-python/issues" [tool.poetry.dependencies] -python = ">=3.7,<4.0" +python = ">=3.8,<4.0" redis = ">=3.5.3,<5.0.0" pydantic = ">=1.10.2,<2.1.0" click = "^8.0.1" From 8d5d4d57cb021f35e5e026a34524c2015b7dbc2d Mon Sep 17 00:00:00 2001 From: "Tom MTT." Date: Thu, 15 Feb 2024 19:09:27 +0100 Subject: [PATCH 10/10] feat!(pyproject.toml): upgrade python, pydantic and python-ulid It sucks having to maintain your own fork just to have up-to-date packages. python^3.8 => python^3.9 (python-ulid^2 requires python^3.9) pydantic^1 => pydantic^2 python-ulid^1 => python-ulid^2 --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 54d3b27..a38626e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "redis-om" -version = "0.2.1" +version = "0.3.0" description = "Object mappings, and more, for Redis." authors = ["Redis OSS "] maintainers = ["Redis OSS "] @@ -17,7 +17,6 @@ classifiers = [ "Operating System :: OS Independent", "Topic :: Database", 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', @@ -34,15 +33,16 @@ include=[ "Issue tracker" = "https://github.com/redis/redis-om-python/issues" [tool.poetry.dependencies] -python = ">=3.8,<4.0" +python = "^3.9" redis = ">=3.5.3,<5.0.0" -pydantic = ">=1.10.2,<2.1.0" +pydantic = "^2.1.0" click = "^8.0.1" types-redis = ">=3.5.9,<5.0.0" -python-ulid = "^1.0.3" +python-ulid = "^2.0.0" typing-extensions = "^4.4.0" hiredis = "^2.2.3" more-itertools = ">=8.14,<10.0" +setuptools = "^69.1.0" [tool.poetry.dev-dependencies] mypy = "^0.982"