Skip to content
Snippets Groups Projects
Commit 21fdbcae authored by Colin Watson's avatar Colin Watson
Browse files

Update upstream source from tag 'upstream/2.12.0'

Update to upstream version '2.12.0'
with Debian dir 39f36d38b324fc88b811c1a8994e188459eb04fa
parents ca30f25c 835fe42b
No related branches found
No related tags found
No related merge requests found
Showing with 112 additions and 82 deletions
...@@ -33,8 +33,8 @@ jobs: ...@@ -33,8 +33,8 @@ jobs:
run: flake8 run: flake8
- name: Prepare twine checker - name: Prepare twine checker
run: | run: |
pip install -U twine wheel pip install -U build twine wheel
python setup.py sdist bdist_wheel python -m build
- name: Run twine checker - name: Run twine checker
run: twine check dist/* run: twine check dist/*
......
...@@ -4,3 +4,4 @@ include_trailing_comma=True ...@@ -4,3 +4,4 @@ include_trailing_comma=True
multi_line_output=3 multi_line_output=3
force_grid_wrap=0 force_grid_wrap=0
combine_as_imports=True combine_as_imports=True
known_first_party=aiohttp_session
...@@ -27,9 +27,6 @@ disallow_any_unimported = False ...@@ -27,9 +27,6 @@ disallow_any_unimported = False
[mypy-aiopg.*] [mypy-aiopg.*]
ignore_missing_imports = True ignore_missing_imports = True
[mypy-aioredis.*]
ignore_missing_imports = True
[mypy-aiomcache.*] [mypy-aiomcache.*]
ignore_missing_imports = True ignore_missing_imports = True
......
...@@ -17,24 +17,24 @@ repos: ...@@ -17,24 +17,24 @@ repos:
pass_filenames: true pass_filenames: true
types: [file, rst] types: [file, rst]
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1' rev: 'v4.3.0'
hooks: hooks:
- id: check-merge-conflict - id: check-merge-conflict
- repo: https://github.com/asottile/yesqa - repo: https://github.com/asottile/yesqa
rev: v1.3.0 rev: v1.4.0
hooks: hooks:
- id: yesqa - id: yesqa
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: '5.9.3' rev: '5.10.1'
hooks: hooks:
- id: isort - id: isort
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: '21.10b0' rev: '22.10.0'
hooks: hooks:
- id: black - id: black
language_version: python3 language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1' rev: 'v4.3.0'
hooks: hooks:
- id: end-of-file-fixer - id: end-of-file-fixer
exclude: >- exclude: >-
...@@ -66,16 +66,16 @@ repos: ...@@ -66,16 +66,16 @@ repos:
- id: detect-private-key - id: detect-private-key
exclude: ^examples/ exclude: ^examples/
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: 'v2.29.0' rev: 'v3.1.0'
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: ['--py36-plus'] args: ['--py36-plus']
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
rev: '4.0.1' rev: '5.0.4'
hooks: hooks:
- id: flake8 - id: flake8
exclude: "^docs/" exclude: "^docs/"
- repo: git://github.com/Lucas-C/pre-commit-hooks-markup - repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1 rev: v1.0.1
hooks: hooks:
- id: rst-linter - id: rst-linter
......
.. towncrier release notes start .. towncrier release notes start
2.12.0 (2022-10-28)
===================
* Migrated from `aioredis` to `redis` (if using redis without installing
`aiohttp-session[aioredis]` then it will be necessary to manually install `redis`).
2.11.0 (2021-01-31) 2.11.0 (2021-01-31)
=================== ===================
......
...@@ -7,7 +7,6 @@ setup: ...@@ -7,7 +7,6 @@ setup:
flake fmt: flake fmt:
python -m pre_commit run --all-files python -m pre_commit run --all-files
test: test:
py.test ./tests/ py.test ./tests/
......
aiohttp_session aiohttp_session
=============== ===============
.. image:: https://travis-ci.com/aio-libs/aiohttp-session.svg?branch=master .. image:: https://github.com/aio-libs/aiohttp-session/actions/workflows/ci.yaml/badge.svg?branch=master
:target: https://travis-ci.com/aio-libs/aiohttp-session :target: https://github.com/aio-libs/aiohttp-session/actions/workflows/ci.yaml
.. image:: https://codecov.io/github/aio-libs/aiohttp-session/coverage.svg?branch=master .. image:: https://codecov.io/github/aio-libs/aiohttp-session/coverage.svg?branch=master
:target: https://codecov.io/github/aio-libs/aiohttp-session :target: https://codecov.io/github/aio-libs/aiohttp-session
.. image:: https://readthedocs.org/projects/aiohttp-session/badge/?version=latest .. image:: https://readthedocs.org/projects/aiohttp-session/badge/?version=latest
...@@ -79,10 +79,8 @@ Available session storages are: ...@@ -79,10 +79,8 @@ Available session storages are:
* ``aiohttp_session.redis_storage.RedisStorage(redis_pool)`` -- stores * ``aiohttp_session.redis_storage.RedisStorage(redis_pool)`` -- stores
JSON encoded data in *redis*, keeping only the redis key (a random UUID) in JSON encoded data in *redis*, keeping only the redis key (a random UUID) in
the cookie. ``redis_pool`` is a ``aioredis`` pool object, created by the cookie. ``redis_pool`` is a ``redis`` object, created by
``await aioredis.create_redis_pool(...)`` call. ``await aioredis.from_url(...)`` call.
Requires ``aioredis`` library (only versions ``1.0+`` are supported)::
$ pip install aiohttp_session[aioredis] $ pip install aiohttp_session[aioredis]
......
"""User sessions for aiohttp.web.""" """User sessions for aiohttp.web."""
__version__ = "2.11.0" __version__ = "2.12.0"
import abc import abc
import json import json
...@@ -304,7 +304,6 @@ class AbstractStorage(metaclass=abc.ABCMeta): ...@@ -304,7 +304,6 @@ class AbstractStorage(metaclass=abc.ABCMeta):
self._cookie_name, domain=params["domain"], path=params["path"] self._cookie_name, domain=params["domain"], path=params["path"]
) )
else: else:
# Ignoring type for params until aiohttp#4238 is released
response.set_cookie(self._cookie_name, cookie_data, **params) response.set_cookie(self._cookie_name, cookie_data, **params)
......
import json import json
import uuid import uuid
from distutils.version import StrictVersion
from typing import Any, Callable, Optional from typing import Any, Callable, Optional
from aiohttp import web from aiohttp import web
...@@ -8,9 +7,17 @@ from aiohttp import web ...@@ -8,9 +7,17 @@ from aiohttp import web
from . import AbstractStorage, Session from . import AbstractStorage, Session
try: try:
import aioredis from redis import VERSION as REDIS_VERSION, asyncio as aioredis
except ImportError: # pragma: no cover except ImportError: # pragma: no cover
aioredis = None # type: ignore[assignment] try:
import aioredis # type: ignore[import, no-redef] # noqa: I900
except ImportError:
aioredis = None # type: ignore[assignment]
else:
import warnings
warnings.warn("aioredis library is deprecated, please replace with redis.",
DeprecationWarning)
REDIS_VERSION = (4, 3)
class RedisStorage(AbstractStorage): class RedisStorage(AbstractStorage):
...@@ -18,7 +25,7 @@ class RedisStorage(AbstractStorage): ...@@ -18,7 +25,7 @@ class RedisStorage(AbstractStorage):
def __init__( def __init__(
self, self,
redis_pool: "aioredis.Redis", redis_pool: "aioredis.Redis[bytes]",
*, *,
cookie_name: str = "AIOHTTP_SESSION", cookie_name: str = "AIOHTTP_SESSION",
domain: Optional[str] = None, domain: Optional[str] = None,
...@@ -43,13 +50,13 @@ class RedisStorage(AbstractStorage): ...@@ -43,13 +50,13 @@ class RedisStorage(AbstractStorage):
decoder=decoder, decoder=decoder,
) )
if aioredis is None: if aioredis is None:
raise RuntimeError("Please install aioredis") raise RuntimeError("Please install redis")
# May have installed aioredis separately (without aiohttp-session[aioredis]). # May have installed aioredis separately (without aiohttp-session[aioredis]).
if StrictVersion(aioredis.__version__).version < (2, 0): if REDIS_VERSION < (4, 3):
raise RuntimeError("aioredis<2.0 is not supported") raise RuntimeError("redis<4.3 is not supported")
self._key_factory = key_factory self._key_factory = key_factory
if not isinstance(redis_pool, aioredis.Redis): if not isinstance(redis_pool, aioredis.Redis):
raise TypeError(f"Expected aioredis.Redis got {type(redis_pool)}") raise TypeError(f"Expected redis.asyncio.Redis got {type(redis_pool)}")
self._redis = redis_pool self._redis = redis_pool
async def load_session(self, request: web.Request) -> Session: async def load_session(self, request: web.Request) -> Session:
...@@ -58,12 +65,12 @@ class RedisStorage(AbstractStorage): ...@@ -58,12 +65,12 @@ class RedisStorage(AbstractStorage):
return Session(None, data=None, new=True, max_age=self.max_age) return Session(None, data=None, new=True, max_age=self.max_age)
else: else:
key = str(cookie) key = str(cookie)
data = await self._redis.get(self.cookie_name + "_" + key) data_bytes = await self._redis.get(self.cookie_name + "_" + key)
if data is None: if data_bytes is None:
return Session(None, data=None, new=True, max_age=self.max_age) return Session(None, data=None, new=True, max_age=self.max_age)
data = data.decode("utf-8") data_str = data_bytes.decode("utf-8")
try: try:
data = self._decoder(data) data = self._decoder(data_str)
except ValueError: except ValueError:
data = None data = None
return Session(key, data=data, new=False, max_age=self.max_age) return Session(key, data=data, new=False, max_age=self.max_age)
...@@ -82,9 +89,9 @@ class RedisStorage(AbstractStorage): ...@@ -82,9 +89,9 @@ class RedisStorage(AbstractStorage):
key = str(key) key = str(key)
self.save_cookie(response, key, max_age=session.max_age) self.save_cookie(response, key, max_age=session.max_age)
data = self._encoder(self._get_session_data(session)) data_str = self._encoder(self._get_session_data(session))
await self._redis.set( await self._redis.set(
self.cookie_name + "_" + key, self.cookie_name + "_" + key,
data, data_str,
ex=session.max_age, # type: ignore[arg-type] ex=session.max_age,
) )
python-aiohttp-session (2.12.0-1) UNRELEASED; urgency=medium
* Team upload.
* New upstream release.
* Replace python3-aioredis build-dependency with python3-redis.
-- Colin Watson <cjwatson@debian.org> Tue, 30 Apr 2024 18:17:42 +0100
python-aiohttp-session (2.11.0-1) unstable; urgency=medium python-aiohttp-session (2.11.0-1) unstable; urgency=medium
* New upstream version * New upstream version
......
...@@ -6,7 +6,6 @@ Uploaders: Martin <debacle@debian.org> ...@@ -6,7 +6,6 @@ Uploaders: Martin <debacle@debian.org>
Build-Depends: debhelper-compat (= 13), Build-Depends: debhelper-compat (= 13),
dh-python, dh-python,
python3-aiohttp, python3-aiohttp,
python3-aioredis,
python3-all, python3-all,
python3-attr, python3-attr,
python3-chardet, python3-chardet,
...@@ -18,6 +17,7 @@ Build-Depends: debhelper-compat (= 13), ...@@ -18,6 +17,7 @@ Build-Depends: debhelper-compat (= 13),
python3-pytest-cov, python3-pytest-cov,
python3-pytest-mock, python3-pytest-mock,
python3-pytest-sugar, python3-pytest-sugar,
python3-redis,
python3-sphinx, python3-sphinx,
python3-yarl, python3-yarl,
Standards-Version: 4.1.5 Standards-Version: 4.1.5
......
Description: fix documentation privacy breaches From: Martin <debacle@debian.org>
Author: Martin <debacle@debian.org> Date: Tue, 30 Apr 2024 18:13:32 +0100
Subject: fix documentation privacy breaches
Origin: vendor Origin: vendor
Last-Update: 2019-12-22
Last-Update: 2019-12-22 Last-Update: 2019-12-22
--- ---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ docs/conf.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index aa82e82..bed5f85 100644
--- a/docs/conf.py --- a/docs/conf.py
+++ b/docs/conf.py +++ b/docs/conf.py
@@ -142,11 +142,11 @@ @@ -142,11 +142,11 @@ html_theme_options = {
"description": "user session support for aiohttp.web", "description": "user session support for aiohttp.web",
"github_user": "aio-libs", "github_user": "aio-libs",
"github_repo": "aiohttp-session", "github_repo": "aiohttp-session",
......
Description: use local docs for intersphinx links From: Martin <debacle@debian.org>
Author: Martin <debacle@debian.org> Date: Tue, 30 Apr 2024 18:13:32 +0100
Subject: use local docs for intersphinx links
Origin: vendor Origin: vendor
Last-Update: 2019-12-22
Last-Update: 2019-12-22 Last-Update: 2019-12-22
--- ---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ docs/conf.py | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index bed5f85..1a47e27 100644
--- a/docs/conf.py --- a/docs/conf.py
+++ b/docs/conf.py +++ b/docs/conf.py
@@ -341,10 +341,5 @@ @@ -341,10 +341,5 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library. # Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = { intersphinx_mapping = {
- "https://docs.python.org/3": None, - "https://docs.python.org/3": None,
- "https://aiohttp.readthedocs.io/en/stable": None, - "https://aiohttp.readthedocs.io/en/stable": None,
- "https://aioredis.readthedocs.io/en/latest": None, - "https://redis.readthedocs.io/en/latest": None,
- # 'https://github.com/aio-libs/aiomcache': None, - # 'https://github.com/aio-libs/aiomcache': None,
- "http://cryptography.io/en/latest": None, - "http://cryptography.io/en/latest": None,
- "https://pynacl.readthedocs.io/en/latest": None, - "https://pynacl.readthedocs.io/en/latest": None,
......
import time import time
from typing import AsyncIterator from typing import AsyncIterator
import aioredis
from aiohttp import web from aiohttp import web
from redis import asyncio as aioredis
from aiohttp_session import get_session, setup from aiohttp_session import get_session, setup
from aiohttp_session.redis_storage import RedisStorage from aiohttp_session.redis_storage import RedisStorage
...@@ -18,10 +18,7 @@ async def handler(request: web.Request) -> web.Response: ...@@ -18,10 +18,7 @@ async def handler(request: web.Request) -> web.Response:
async def redis_pool(app: web.Application) -> AsyncIterator[None]: async def redis_pool(app: web.Application) -> AsyncIterator[None]:
redis_address = "redis://127.0.0.1:6379" redis_address = "redis://127.0.0.1:6379"
async with aioredis.from_url( # type: ignore[no-untyped-call] async with aioredis.from_url(redis_address) as redis:
redis_address,
timeout=1,
) as redis:
storage = RedisStorage(redis) storage = RedisStorage(redis)
setup(app, storage) setup(app, storage)
yield yield
......
...@@ -343,7 +343,7 @@ texinfo_documents = [ ...@@ -343,7 +343,7 @@ texinfo_documents = [
intersphinx_mapping = { intersphinx_mapping = {
"https://docs.python.org/3": None, "https://docs.python.org/3": None,
"https://aiohttp.readthedocs.io/en/stable": None, "https://aiohttp.readthedocs.io/en/stable": None,
"https://aioredis.readthedocs.io/en/latest": None, "https://redis.readthedocs.io/en/latest": None,
# 'https://github.com/aio-libs/aiomcache': None, # 'https://github.com/aio-libs/aiomcache': None,
"http://cryptography.io/en/latest": None, "http://cryptography.io/en/latest": None,
"https://pynacl.readthedocs.io/en/latest": None, "https://pynacl.readthedocs.io/en/latest": None,
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
aioredis aioredis
:term:`asyncio` compatible Redis client library :term:`asyncio` compatible module in the :term:`redis` library.
https://aioredis.readthedocs.io/ https://redis-py.readthedocs.io/en/stable/examples/asyncio_examples.html
aiomcache aiomcache
......
...@@ -79,7 +79,7 @@ Available session storages are: ...@@ -79,7 +79,7 @@ Available session storages are:
``e33b57c7ec6e425eb626610f811ab6ae`` (a random UUID) they key inside ``e33b57c7ec6e425eb626610f811ab6ae`` (a random UUID) they key inside
redis will be ``AIOHTTP_SESSION_e33b57c7ec6e425eb626610f811ab6ae``. redis will be ``AIOHTTP_SESSION_e33b57c7ec6e425eb626610f811ab6ae``.
Requires :term:`aioredis` library: Requires :term:`redis` library:
.. code-block:: bash .. code-block:: bash
...@@ -121,7 +121,7 @@ Dependencies ...@@ -121,7 +121,7 @@ Dependencies
- :term:`cryptography` for - :term:`cryptography` for
:class:`~aiohttp_session.cookie_storage.EncryptedCookieStorage` :class:`~aiohttp_session.cookie_storage.EncryptedCookieStorage`
- :term:`aioredis` for - :term:`redis` for
:class:`~aiohttp_session.redis_storage.RedisStorage` :class:`~aiohttp_session.redis_storage.RedisStorage`
......
...@@ -378,11 +378,11 @@ Redis Storage ...@@ -378,11 +378,11 @@ Redis Storage
The storage that stores session data in Redis database and The storage that stores session data in Redis database and
keeps only Redis keys (UUIDs actually) in HTTP cookies. keeps only Redis keys (UUIDs actually) in HTTP cookies.
It operates with Redis database via :class:`aioredis.RedisPool`. It operates with Redis database via :class:`redis.asyncio.Redis`.
To use the storage you need setup it first:: To use the storage you need setup it first::
redis = await aioredis.create_pool(('localhost', 6379)) redis = await aioredis.from_url("redis://127.0.0.1:6379")
storage = aiohttp_session.redis_storage.RedisStorage(redis) storage = aiohttp_session.redis_storage.RedisStorage(redis)
aiohttp_session.setup(app, storage) aiohttp_session.setup(app, storage)
...@@ -398,10 +398,10 @@ To use the storage you need setup it first:: ...@@ -398,10 +398,10 @@ To use the storage you need setup it first::
The class is inherited from :class:`~aiohttp_session.AbstractStorage`. The class is inherited from :class:`~aiohttp_session.AbstractStorage`.
*redis_pool* is a :class:`~aioredis.RedisPool` which should be *redis_pool* is a :class:`~redis.asyncio.Redis` which should be
created by :func:`~aioredis.create_pool` call, e.g.:: created by :func:`~redis.asyncio.from_url` call, e.g.::
redis = await aioredis.create_pool(('localhost', 6379)) redis = await aioredis.from_url("redis://localhost:6379")
storage = aiohttp_session.redis_storage.RedisStorage(redis) storage = aiohttp_session.redis_storage.RedisStorage(redis)
Other parameters are the same as for Other parameters are the same as for
...@@ -409,7 +409,7 @@ To use the storage you need setup it first:: ...@@ -409,7 +409,7 @@ To use the storage you need setup it first::
Memcached Storage Memcached Storage
---------------- -----------------
The storage that stores session data in Memcached and The storage that stores session data in Memcached and
keeps only keys (UUIDs actually) in HTTP cookies. keeps only keys (UUIDs actually) in HTTP cookies.
......
[pytest] [pytest]
asyncio_mode = auto
filterwarnings= filterwarnings=
error error
# This is internal to the docker library. # This is internal to the docker library.
......
-e . -e .
aiohttp==3.8.1 aiohttp==3.8.3
aiomcache==0.7.0 aiomcache==0.7.0
aioredis==2.0.0 attrs==22.1.0
attrs==21.4.0 chardet==5.0.0
chardet==4.0.0 cryptography==38.0.1
cryptography==36.0.1 docker==6.0.0
docker==5.0.3 flake8==5.0.4
flake8==4.0.1 flake8-bandit==4.1.1
flake8-bandit==2.1.2 flake8-bugbear==22.10.27
flake8-bugbear==22.1.11
flake8-import-order==0.18.1 flake8-import-order==0.18.1
flake8-requirements==1.5.2 flake8-requirements==1.7.3
multidict==6.0.2 multidict==6.0.2
mypy==0.930 mypy==0.982
pep257==0.7.0 pep257==0.7.0
pre-commit==2.17.0 pre-commit==2.20.0
pynacl==1.5.0 pynacl==1.5.0
pytest==6.2.5 pytest==7.2.0
pytest-aiohttp==1.0.3 pytest-aiohttp==1.0.4
pytest-cov==3.0.0 pytest-cov==4.0.0
pytest-mock==3.7.0 pytest-mock==3.10.0
pytest-sugar==0.9.4 pytest-sugar==0.9.5
redis==4.3.4
sphinx==4.3.2 sphinx==4.3.2
typing-extensions==4.0.1 types-redis==4.3.21.3
yarl==1.7.2 typing-extensions==4.4.0
yarl==1.8.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment