From 4bbfbf6fc0be93f985f5319740f33118acb0333e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 10:37:00 +0000 Subject: [PATCH 1/2] Bump black from 22.8.0 to 24.3.0 Bumps [black](https://github.com/psf/black) from 22.8.0 to 24.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/22.8.0...24.3.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 30aec00e..31bb8984 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ pytest-lazy-fixture==0.6.3 redis==4.5.4 redislite twine==3.8.0 -black==22.8.0 +black==24.3.0 pre-commit build pytest-asyncio From 989a00224e695fe2bf3b52fead98447df083d9e4 Mon Sep 17 00:00:00 2001 From: Martin Ahindura Date: Mon, 24 Jun 2024 12:45:12 +0200 Subject: [PATCH 2/2] Format with the latest version of black --- pydantic_redis/_shared/model/base.py | 1 + pydantic_redis/_shared/model/delete_utils.py | 1 + pydantic_redis/_shared/model/insert_utils.py | 19 +++++++++++-------- pydantic_redis/_shared/model/select_utils.py | 1 + pydantic_redis/_shared/store.py | 1 + pydantic_redis/_shared/utils.py | 1 + pydantic_redis/asyncio/model.py | 1 + pydantic_redis/asyncio/store.py | 1 + pydantic_redis/config.py | 1 + pydantic_redis/syncio/model.py | 1 + pydantic_redis/syncio/store.py | 1 + test/test_async_pydantic_redis.py | 1 + test/test_benchmarks.py | 1 + test/test_pydantic_redis.py | 1 + 14 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pydantic_redis/_shared/model/base.py b/pydantic_redis/_shared/model/base.py index cb68a858..2d52d501 100644 --- a/pydantic_redis/_shared/model/base.py +++ b/pydantic_redis/_shared/model/base.py @@ -1,6 +1,7 @@ """Exposes the Base `Model` common to both async and sync APIs """ + import typing from typing import Dict, Tuple, Any, Type, Union, List, Optional diff --git a/pydantic_redis/_shared/model/delete_utils.py b/pydantic_redis/_shared/model/delete_utils.py index a5736cac..2be71712 100644 --- a/pydantic_redis/_shared/model/delete_utils.py +++ b/pydantic_redis/_shared/model/delete_utils.py @@ -1,6 +1,7 @@ """Exposes shared utilities for deleting records from redis """ + from typing import Type, Union, List from redis.client import Pipeline diff --git a/pydantic_redis/_shared/model/insert_utils.py b/pydantic_redis/_shared/model/insert_utils.py index ef45f767..aae524bc 100644 --- a/pydantic_redis/_shared/model/insert_utils.py +++ b/pydantic_redis/_shared/model/insert_utils.py @@ -1,6 +1,7 @@ """Exposes the utility functions for inserting records into redis. """ + from datetime import datetime from typing import Union, Optional, Any, Dict, Tuple, List, Type @@ -145,15 +146,17 @@ def _serialize_tuple( try: field_types = tuple_fields.get(key, ()) value = [ - insert_on_pipeline( - model=field_type, - _id=None, - pipeline=pipeline, - record=item, - life_span=life_span, + ( + insert_on_pipeline( + model=field_type, + _id=None, + pipeline=pipeline, + record=item, + life_span=life_span, + ) + if issubclass(field_type, AbstractModel) + else item ) - if issubclass(field_type, AbstractModel) - else item for field_type, item in zip(field_types, value) ] key = f"{NESTED_MODEL_TUPLE_FIELD_PREFIX}{key}" diff --git a/pydantic_redis/_shared/model/select_utils.py b/pydantic_redis/_shared/model/select_utils.py index 95c2d486..33e0f842 100644 --- a/pydantic_redis/_shared/model/select_utils.py +++ b/pydantic_redis/_shared/model/select_utils.py @@ -1,6 +1,7 @@ """Exposes utilities for selecting records from redis using lua scripts. """ + from typing import List, Any, Type, Union, Awaitable, Optional from pydantic_redis._shared.model.prop_utils import ( diff --git a/pydantic_redis/_shared/store.py b/pydantic_redis/_shared/store.py index 5ecd7772..0335579e 100644 --- a/pydantic_redis/_shared/store.py +++ b/pydantic_redis/_shared/store.py @@ -1,6 +1,7 @@ """Exposes base Store class common to both sync and async """ + from typing import Optional, Union, Type, Dict, Any from pydantic.fields import ModelPrivateAttr diff --git a/pydantic_redis/_shared/utils.py b/pydantic_redis/_shared/utils.py index 7bedb6a8..8fa95db7 100644 --- a/pydantic_redis/_shared/utils.py +++ b/pydantic_redis/_shared/utils.py @@ -1,6 +1,7 @@ """Exposes common utilities. """ + import typing from typing import Any, Tuple, Optional, Union, Dict, Type, List diff --git a/pydantic_redis/asyncio/model.py b/pydantic_redis/asyncio/model.py index 62aa5dde..502d60c2 100644 --- a/pydantic_redis/asyncio/model.py +++ b/pydantic_redis/asyncio/model.py @@ -3,6 +3,7 @@ This module contains the `Model` class which should be inherited when creating model's for use in the asynchronous API of pydantic-redis. """ + from typing import Optional, List, Any, Union, Dict from .._shared.model import AbstractModel diff --git a/pydantic_redis/asyncio/store.py b/pydantic_redis/asyncio/store.py index 599bbcbd..0157d43b 100644 --- a/pydantic_redis/asyncio/store.py +++ b/pydantic_redis/asyncio/store.py @@ -8,6 +8,7 @@ A model must be registered with a store before it can interact with a redis database. """ + from typing import Dict, Type, TYPE_CHECKING from redis import asyncio as redis diff --git a/pydantic_redis/config.py b/pydantic_redis/config.py index a64b400e..3d3744d2 100644 --- a/pydantic_redis/config.py +++ b/pydantic_redis/config.py @@ -1,5 +1,6 @@ """Exposes the configuration for connecting to a redis database. """ + from typing import Optional from pydantic import ConfigDict, BaseModel diff --git a/pydantic_redis/syncio/model.py b/pydantic_redis/syncio/model.py index d8ff5833..8f2ff583 100644 --- a/pydantic_redis/syncio/model.py +++ b/pydantic_redis/syncio/model.py @@ -3,6 +3,7 @@ This module contains the `Model` class which should be inherited when creating model's for use in the synchronous API of pydantic-redis """ + from typing import Optional, List, Any, Union, Dict from .._shared.model import AbstractModel diff --git a/pydantic_redis/syncio/store.py b/pydantic_redis/syncio/store.py index 8cd1b71c..207b1861 100644 --- a/pydantic_redis/syncio/store.py +++ b/pydantic_redis/syncio/store.py @@ -8,6 +8,7 @@ A model must be registered with a store before it can interact with a redis database. """ + from typing import Dict, Type, TYPE_CHECKING import redis diff --git a/test/test_async_pydantic_redis.py b/test/test_async_pydantic_redis.py index f7191bf5..a90e19fa 100644 --- a/test/test_async_pydantic_redis.py +++ b/test/test_async_pydantic_redis.py @@ -1,4 +1,5 @@ """Tests for the redis orm""" + from collections import namedtuple from typing import Dict, Any diff --git a/test/test_benchmarks.py b/test/test_benchmarks.py index 3a24d7f5..46647be9 100644 --- a/test/test_benchmarks.py +++ b/test/test_benchmarks.py @@ -1,4 +1,5 @@ """Tests for benchmarks""" + import pytest from test.conftest import ( diff --git a/test/test_pydantic_redis.py b/test/test_pydantic_redis.py index d0bd9a34..a3ddca41 100644 --- a/test/test_pydantic_redis.py +++ b/test/test_pydantic_redis.py @@ -1,4 +1,5 @@ """Tests for the redis orm""" + from collections import namedtuple from typing import Dict, Any, Union