Skip to content

Commit 3a774d1

Browse files
authored
Adjust supported framework versions, add support for Python 3.11 (#76)
- Adjusted Flask support (`>=2.0,<2.3`) - Adjusted Sanic support (`>=21,<23`) - added support for Django 4.2 - validated Python 3.11 compatibility - make code changes to account for new framework support - alphabetized author list - updated changelog
1 parent f9da1eb commit 3a774d1

File tree

25 files changed

+118
-187
lines changed

25 files changed

+118
-187
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ['3.7', '3.8', '3.9', '3.10']
12+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1313

1414
# Service containers to run with `container-job`
1515
services:

AUTHORS.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
- Peter Bengtsson (@peterbe)
2+
- Graham Beckley (@grahamalama)
23
- Mike Cooper (@mythmon)
34
- Will Kahn-Greene (@willkg)
45
- Michael Kelly (@Osmose)
56
- Jannis Leidel (@jezdez)
6-
- Les Orchard (@lmorchard)
77
- Mathieu Leplatre (@leplatrem)
8+
- Les Orchard (@lmorchard)
89
- Mathieu Pillard (@diox)

docs/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changelog
22
---------
33

4+
2023.8.0
5+
~~~~~~~~~~~~~~~~~~~~~
6+
7+
- Add support for Django 4.2
8+
9+
- Drop support for Sanic 20
10+
11+
- Drop support for Flask 0.12, 1.0, and 1.1
12+
13+
- Add support for Python 3.11
14+
415
2022.8.0 (2022-08-18)
516
~~~~~~~~~~~~~~~~~~~~~
617

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.black]
22
line-length = 88
3-
target-version = ['py37', 'py38', 'py39', 'py310']
3+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
44
include = '\.pyi?$'
55
exclude = '''
66
/(

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def read(*parts):
4040
"Programming Language :: Python :: 3.8",
4141
"Programming Language :: Python :: 3.9",
4242
"Programming Language :: Python :: 3.10",
43+
"Programming Language :: Python :: 3.11",
4344
"Topic :: Internet :: WWW/HTTP",
4445
],
4546
extras_require={

src/dockerflow/django/middleware.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,10 @@
33
import time
44
import uuid
55

6-
from django import VERSION
6+
from django.utils.deprecation import MiddlewareMixin
77

88
from . import views
99

10-
try:
11-
from django.utils.deprecation import MiddlewareMixin
12-
except ImportError: # pragma: no cover
13-
MiddlewareMixin = object
14-
15-
16-
# Computed once, reused in every request
17-
_less_than_django_1_10 = VERSION < (1, 10)
18-
19-
20-
def is_authenticated(user): # pragma: no cover
21-
"""Check if the user is authenticated but do it in a way that
22-
it doesnt' cause a DeprecationWarning in Django >=1.10"""
23-
if _less_than_django_1_10:
24-
# Prior to Django 1.10, user.is_authenticated was a method
25-
return user.is_authenticated()
26-
return user.is_authenticated
27-
2810

2911
class DockerflowMiddleware(MiddlewareMixin):
3012
"""
@@ -66,7 +48,7 @@ def _build_extra_meta(self, request):
6648
# modified earlier, so be sure to check for existence of these
6749
# attributes before trying to use them.
6850
if hasattr(request, "user"):
69-
out["uid"] = is_authenticated(request.user) and request.user.pk or ""
51+
out["uid"] = request.user.is_authenticated and request.user.pk or ""
7052
if hasattr(request, "_id"):
7153
out["rid"] = request._id
7254
if hasattr(request, "_start_timestamp"):

src/dockerflow/flask/checks/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"""
55
This module contains a few built-in checks for the Flask integration.
66
"""
7+
from sqlalchemy import text
8+
79
from ... import health
810
from ...checks import ( # noqa
911
CRITICAL,
@@ -47,7 +49,7 @@ def check_database_connected(db):
4749
errors = []
4850
try:
4951
with db.engine.connect() as connection:
50-
connection.execute("SELECT 1;")
52+
connection.execute(text("SELECT 1;"))
5153
except DBAPIError as e:
5254
msg = "DB-API error: {!s}".format(e)
5355
errors.append(Error(msg, id=health.ERROR_DB_API_EXCEPTION))

src/dockerflow/sanic/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def __init__(
8484
*args,
8585
**kwargs,
8686
):
87-
8887
# The Dockerflow specific logger to be used by internals of this
8988
# extension.
9089
self.logger = logging.getLogger("dockerflow.sanic")

src/dockerflow/sanic/checks.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424

25-
async def check_redis_connected(redis):
25+
async def check_redis_connected(redis_client):
2626
"""
2727
A built-in check to connect to Redis using the given client and see
2828
if it responds to the ``PING`` command.
@@ -54,22 +54,17 @@ async def check_redis_connected(redis):
5454
dockerflow = Dockerflow(app, redis=redis)
5555
5656
"""
57-
import aioredis
58-
59-
if aioredis.__version__.startswith("1."):
60-
RedisConnectionError = aioredis.ConnectionClosedError
61-
else:
62-
RedisConnectionError = aioredis.ConnectionError
57+
import redis
6358

6459
errors = []
6560

6661
try:
67-
with await redis.conn as r:
62+
with await redis_client.conn as r:
6863
result = await r.ping()
69-
except RedisConnectionError as e:
64+
except redis.ConnectionError as e:
7065
msg = "Could not connect to redis: {!s}".format(e)
7166
errors.append(Error(msg, id=health.ERROR_CANNOT_CONNECT_REDIS))
72-
except aioredis.RedisError as e:
67+
except redis.RedisError as e:
7368
errors.append(
7469
Error('Redis error: "{!s}"'.format(e), id=health.ERROR_REDIS_EXCEPTION)
7570
)

tests/constraints/django-4.2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Django>=4.2,<4.3

0 commit comments

Comments
 (0)