From 2dc830d784e3bc7af547a9aae26fb8297cf70504 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 00:07:31 +0000 Subject: [PATCH 01/10] Bump redis from 5.0.0 to 5.0.1 Bumps [redis](https://github.com/redis/redis-py) from 5.0.0 to 5.0.1. - [Release notes](https://github.com/redis/redis-py/releases) - [Changelog](https://github.com/redis/redis-py/blob/master/CHANGES) - [Commits](https://github.com/redis/redis-py/compare/v5.0.0...v5.0.1) --- updated-dependencies: - dependency-name: redis dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 91f2387d..81ad2cd9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,5 @@ pytest-aiohttp==1.0.5 pytest-cov==4.1.0 pytest-mock==3.12.0 pytest-sugar==0.9.7 -redis==5.0.0 +redis==5.0.1 yarl==1.9.2 From 7eeaad4c353d0981191a5f618465af953c23412a Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:14:15 +0000 Subject: [PATCH 02/10] Update test_redis_storage.py --- tests/test_redis_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_redis_storage.py b/tests/test_redis_storage.py index 69dc17df..4c7351ee 100644 --- a/tests/test_redis_storage.py +++ b/tests/test_redis_storage.py @@ -291,7 +291,7 @@ async def handler(request: web.Request) -> web.Response: # type: ignore[empty-b redis = aioredis.from_url(redis_url) create_app(handler=handler, redis=redis) - await redis.close() + await redis.aclose() async def test_not_redis_provided_to_storage() -> None: From d96f068cbbf7ae0ca4c08addd53654667459f5e1 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:15:20 +0000 Subject: [PATCH 03/10] Update conftest.py --- tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 88731dd0..0bd91ce7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -99,7 +99,7 @@ async def redis_server( # type: ignore[misc] # No docker types. time.sleep(delay) delay *= 2 finally: - await conn.close() + await conn.aclose() else: # pragma: no cover pytest.fail("Cannot start redis server") @@ -124,7 +124,7 @@ async def start(pool: aioredis.ConnectionPool) -> aioredis.Redis[bytes]: pool = aioredis.ConnectionPool.from_url(redis_url) redis = await start(pool) yield redis - await redis.close() + await redis.aclose() await pool.disconnect() From 866af50d7daafc160425b0f1037ad4ac4dd46e68 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:17:44 +0000 Subject: [PATCH 04/10] Update requirements-dev.txt --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 1d1b8932..3334c5e6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,5 +9,5 @@ mypy==1.6.1 pep257==0.7.0 pre-commit==3.5.0 sphinx==7.2.6 -types-redis==4.6.0.6 +types-redis==4.6.0.10 typing-extensions==4.8.0 From 6687066c0a70ad8dc95dcb94d4427e43a2418a91 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:21:40 +0000 Subject: [PATCH 05/10] Update redis_storage.py --- aiohttp_session/redis_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp_session/redis_storage.py b/aiohttp_session/redis_storage.py index 111f1a8f..5088c491 100644 --- a/aiohttp_session/redis_storage.py +++ b/aiohttp_session/redis_storage.py @@ -55,7 +55,7 @@ def __init__( if REDIS_VERSION < (4, 3): raise RuntimeError("redis<4.3 is not supported") self._key_factory = key_factory - if not isinstance(redis_pool, aioredis.Redis): + if not isinstance(redis_pool, aioredis.Redis): # type: ignore[unreachable] raise TypeError(f"Expected redis.asyncio.Redis got {type(redis_pool)}") self._redis = redis_pool From 4833133a038be278ce89b520bacf66cb92bc124b Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:24:37 +0000 Subject: [PATCH 06/10] Update requirements-dev.txt --- requirements-dev.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 3334c5e6..fa9aaa98 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,5 +9,4 @@ mypy==1.6.1 pep257==0.7.0 pre-commit==3.5.0 sphinx==7.2.6 -types-redis==4.6.0.10 typing-extensions==4.8.0 From 279f042e5904bcb090bb2665ec8a9ef2e4fdbf7e Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:27:28 +0000 Subject: [PATCH 07/10] Update conftest.py --- tests/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0bd91ce7..e50e7ef5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -92,7 +92,7 @@ async def redis_server( # type: ignore[misc] # No docker types. delay = 0.1 for _i in range(20): # pragma: no cover try: - conn = aioredis.from_url(f"redis://{host}:{port}") + conn = aioredis.from_url(f"redis://{host}:{port}") # type: ignore[no-untyped-call] await conn.set("foo", "bar") break except aioredis.ConnectionError: @@ -117,8 +117,8 @@ def redis_url(redis_server: _ContainerInfo) -> str: # type: ignore[misc] @pytest.fixture async def redis( redis_url: str, -) -> AsyncIterator[aioredis.Redis[bytes]]: - async def start(pool: aioredis.ConnectionPool) -> aioredis.Redis[bytes]: +) -> AsyncIterator[aioredis.Redis]: + async def start(pool: aioredis.ConnectionPool) -> aioredis.Redis: return aioredis.Redis(connection_pool=pool) pool = aioredis.ConnectionPool.from_url(redis_url) From 22fefea64be82036e7b3337b017e7b099e6765f2 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:28:38 +0000 Subject: [PATCH 08/10] Update redis_storage.py --- aiohttp_session/redis_storage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiohttp_session/redis_storage.py b/aiohttp_session/redis_storage.py index 5088c491..b48455c7 100644 --- a/aiohttp_session/redis_storage.py +++ b/aiohttp_session/redis_storage.py @@ -25,7 +25,7 @@ class RedisStorage(AbstractStorage): def __init__( self, - redis_pool: "aioredis.Redis[bytes]", + redis_pool: "aioredis.Redis", *, cookie_name: str = "AIOHTTP_SESSION", domain: Optional[str] = None, @@ -55,7 +55,7 @@ def __init__( if REDIS_VERSION < (4, 3): raise RuntimeError("redis<4.3 is not supported") self._key_factory = key_factory - if not isinstance(redis_pool, aioredis.Redis): # type: ignore[unreachable] + if not isinstance(redis_pool, aioredis.Redis): raise TypeError(f"Expected redis.asyncio.Redis got {type(redis_pool)}") self._redis = redis_pool From 724673f1a7010782be1462f2a468f1f904610fcc Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:29:36 +0000 Subject: [PATCH 09/10] Update redis_storage.py --- demo/redis_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/redis_storage.py b/demo/redis_storage.py index 126195f3..ef7d5ae6 100644 --- a/demo/redis_storage.py +++ b/demo/redis_storage.py @@ -18,7 +18,7 @@ async def handler(request: web.Request) -> web.Response: async def redis_pool(app: web.Application) -> AsyncIterator[None]: redis_address = "redis://127.0.0.1:6379" - async with aioredis.from_url(redis_address) as redis: + async with aioredis.from_url(redis_address) as redis: # type: ignore[no-untyped-call] storage = RedisStorage(redis) setup(app, storage) yield From e1648c7e06c488cf4bf3a16e67ad2e7a586e5c3e Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 18 Nov 2023 17:33:25 +0000 Subject: [PATCH 10/10] Update test_redis_storage.py --- tests/test_redis_storage.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/test_redis_storage.py b/tests/test_redis_storage.py index 4c7351ee..4c72b59b 100644 --- a/tests/test_redis_storage.py +++ b/tests/test_redis_storage.py @@ -21,7 +21,7 @@ def create_app( handler: Handler, - redis: aioredis.Redis[bytes], + redis: aioredis.Redis, max_age: Optional[int] = None, key_factory: Callable[[], str] = lambda: uuid.uuid4().hex, ) -> web.Application: @@ -34,7 +34,7 @@ def create_app( async def make_cookie( - client: TestClient, redis: aioredis.Redis[bytes], data: Dict[Any, Any] + client: TestClient, redis: aioredis.Redis, data: Dict[Any, Any] ) -> None: session_data = {"session": data, "created": int(time.time())} value = json.dumps(session_data) @@ -43,13 +43,13 @@ async def make_cookie( client.session.cookie_jar.update_cookies({"AIOHTTP_SESSION": key}) -async def make_cookie_with_bad_value(client: TestClient, redis: aioredis.Redis[bytes]) -> None: +async def make_cookie_with_bad_value(client: TestClient, redis: aioredis.Redis) -> None: key = uuid.uuid4().hex await redis.set("AIOHTTP_SESSION_" + key, "") client.session.cookie_jar.update_cookies({"AIOHTTP_SESSION": key}) -async def load_cookie(client: TestClient, redis: aioredis.Redis[bytes]) -> Any: +async def load_cookie(client: TestClient, redis: aioredis.Redis) -> Any: cookies = client.session.cookie_jar.filter_cookies(client.make_url("/")) key = cookies["AIOHTTP_SESSION"] value_bytes = await redis.get("AIOHTTP_SESSION_" + key.value) @@ -57,7 +57,7 @@ async def load_cookie(client: TestClient, redis: aioredis.Redis[bytes]) -> Any: async def test_create_new_session( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -73,7 +73,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_load_existing_session( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -90,7 +90,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_load_bad_session( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -107,7 +107,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_change_session( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -134,7 +134,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_clear_cookie_on_session_invalidation( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -155,7 +155,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_create_cookie_in_handler( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -182,7 +182,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_set_ttl_on_session_saving( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -202,7 +202,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_set_ttl_manually_set( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -223,7 +223,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_create_new_session_if_key_doesnt_exists_in_redis( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -237,7 +237,7 @@ async def handler(request: web.Request) -> web.StreamResponse: async def test_create_storage_with_custom_key_factory( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -260,7 +260,7 @@ def key_factory() -> str: async def test_redis_session_fixation( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def login(request: web.Request) -> web.StreamResponse: session = await get_session(request) @@ -289,7 +289,7 @@ async def test_redis_from_create_pool(redis_url: str) -> None: async def handler(request: web.Request) -> web.Response: # type: ignore[empty-body] """Dummy handler""" - redis = aioredis.from_url(redis_url) + redis = aioredis.from_url(redis_url) # type: ignore[no-untyped-call] create_app(handler=handler, redis=redis) await redis.aclose() @@ -321,7 +321,7 @@ async def handler(request: web.Request) -> web.Response: # type: ignore[empty-b async def test_load_session_dont_load_expired_session( - aiohttp_client: AiohttpClient, redis: aioredis.Redis[bytes] + aiohttp_client: AiohttpClient, redis: aioredis.Redis ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request)