diff --git a/CHANGELOG.md b/CHANGELOG.md index 5295e99c..292071d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added + +### Changed + +- [BREAKING CHANGE] Removed the 'redis_store' argument from the `Store` constructor +- [BREAKING CHANGE] Made the 'redis_store' property of the `Store` readonly + +### Fixed + +- Fixed the rendering of the reference docs from the docstrings + ## [0.5.0] - 2024-02-10 ### Added diff --git a/pydantic_redis/_shared/store.py b/pydantic_redis/_shared/store.py index 0335579e..25af86f1 100644 --- a/pydantic_redis/_shared/store.py +++ b/pydantic_redis/_shared/store.py @@ -34,7 +34,6 @@ class AbstractStore(BaseModel): name: str redis_config: RedisConfig - redis_store: Optional[Union[Redis, AioRedis]] = None life_span_in_seconds: Optional[int] = None select_all_fields_for_all_ids_script: Optional[Union[AsyncScript, Script]] = None paginated_select_all_fields_for_all_ids_script: Optional[ @@ -49,25 +48,31 @@ class AbstractStore(BaseModel): models: Dict[str, Type["AbstractModel"]] = {} model_config = ConfigDict(arbitrary_types_allowed=True, from_attributes=True) + # protected properties + _redis_store: Optional[Union[Redis, AioRedis]] = None + def __init__( self, name: str, redis_config: RedisConfig, - redis_store: Optional[Union[Redis, AioRedis]] = None, life_span_in_seconds: Optional[int] = None, **data: Any, ): super().__init__( name=name, redis_config=redis_config, - redis_store=redis_store, life_span_in_seconds=life_span_in_seconds, **data, ) - self.redis_store = self._connect_to_redis() + self._redis_store = self._connect_to_redis() self._register_lua_scripts() + @property + def redis_store(self) -> Optional[Union[Redis, AioRedis]]: + """the redis store for the given store""" + return self._redis_store + def _connect_to_redis(self) -> Union[Redis, AioRedis]: """Connects the store to redis. diff --git a/pydantic_redis/asyncio/store.py b/pydantic_redis/asyncio/store.py index 0157d43b..a340b3e7 100644 --- a/pydantic_redis/asyncio/store.py +++ b/pydantic_redis/asyncio/store.py @@ -30,7 +30,6 @@ class Store(AbstractStore): Model name name (str): the name of this Store redis_config (pydantic_redis.syncio.RedisConfig): the configuration for connecting to a redis database - redis_store (Optional[redis.Redis]): an Redis instance associated with this store (default: None) life_span_in_seconds (Optional[int]): the default time-to-live for the records inserted in this store (default: None) """ diff --git a/pydantic_redis/syncio/store.py b/pydantic_redis/syncio/store.py index 207b1861..9331ad6c 100644 --- a/pydantic_redis/syncio/store.py +++ b/pydantic_redis/syncio/store.py @@ -30,7 +30,6 @@ class Store(AbstractStore): Model name name (str): the name of this Store redis_config (pydantic_redis.syncio.RedisConfig): the configuration for connecting to a redis database - redis_store (Optional[redis.Redis]): an Redis instance associated with this store (default: None) life_span_in_seconds (Optional[int]): the default time-to-live for the records inserted in this store (default: None) """