Skip to content

Commit 17768cd

Browse files
authored
Support Python 3.11 and Django 4.1 (#76)
1 parent 126cf91 commit 17768cd

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
tests:
1111
runs-on: ubuntu-latest
1212
strategy:
13+
fail-fast: false
1314
matrix:
1415
include:
1516
- python: "3.7"
@@ -30,6 +31,8 @@ jobs:
3031
tox_env: py38-django32
3132
- python: "3.8"
3233
tox_env: py38-django40
34+
- python: "3.8"
35+
tox_env: py38-django41
3336
- python: "3.9"
3437
tox_env: py39-django22
3538
- python: "3.9"
@@ -40,16 +43,22 @@ jobs:
4043
tox_env: py39-django32
4144
- python: "3.9"
4245
tox_env: py39-django40
46+
- python: "3.9"
47+
tox_env: py39-django41
4348
- python: "3.10"
4449
tox_env: py310-django32
4550
- python: "3.10"
4651
tox_env: py310-django40
52+
- python: "3.10"
53+
tox_env: py310-django41
54+
- python: "3.11"
55+
tox_env: py311-django41
4756
- python: "3.7"
4857
tox_env: checks
4958
name: ${{ matrix.tox_env }}
5059
steps:
51-
- uses: actions/checkout@v2
52-
- uses: actions/setup-python@v2
60+
- uses: actions/checkout@v3
61+
- uses: actions/setup-python@v4
5362
with:
5463
python-version: ${{ matrix.python }}
5564
- run: pip install tox

django_enumfield/db/fields.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@
1515
try:
1616
from functools import partialmethod as _partialmethod
1717

18-
def partialishmethod(method):
19-
return _partialmethod(method)
18+
class partialishmethod(_partialmethod):
19+
"""Workaround for https://github.com/python/cpython/issues/99152"""
20+
21+
def __get__(self, obj, cls=None):
22+
return self._make_unbound_method().__get__(obj, cls)
2023

2124
except ImportError: # pragma: no cover
2225
# This path can be dropped after support for Django 2.2 has been removed.
2326
from django.utils.functional import curry # type: ignore[attr-defined]
2427

25-
def partialishmethod(method):
28+
def partialishmethod(method): # type: ignore[no-redef]
2629
return curry(method)
2730

2831

2932
class EnumField(models.IntegerField):
30-
"""EnumField is a convenience field to automatically handle validation of transitions
33+
"""EnumField is a convenience field to automatically handle validation of transition
3134
between Enum values and set field choices from the enum.
3235
EnumField(MyEnum, default=MyEnum.INITIAL)
3336
"""

django_enumfield/enum.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@
22

33
import logging
44
import enum
5-
from typing import Any, List, Optional, Sequence, Tuple, TypeVar, Union, cast, Mapping
5+
from typing import (
6+
Any,
7+
List,
8+
Optional,
9+
Sequence,
10+
Tuple,
11+
TypeVar,
12+
Union,
13+
cast,
14+
Mapping,
15+
TYPE_CHECKING,
16+
)
617
from django.utils.encoding import force_str
718

19+
if TYPE_CHECKING:
20+
from django.utils.functional import _StrOrPromise as StrOrPromise
21+
822
try:
923
from django.utils.functional import classproperty # type: ignore
1024
except ImportError:
@@ -47,7 +61,7 @@ def __get__(self, instance, cls=None):
4761
class Enum(enum.IntEnum):
4862
"""A container for holding and restoring enum values"""
4963

50-
__labels__ = {} # type: Mapping[int, str]
64+
__labels__ = {} # type: Mapping[int, StrOrPromise]
5165
__default__ = None # type: Optional[int]
5266
__transitions__ = {} # type: Mapping[int, Sequence[int]]
5367

tox.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ envlist =
44
py38-django{22,30,31,32,40}
55
py39-django{22,30,31,32,40}
66
py310-django{32,40}
7+
py311-django{40,41}
78
checks
89

910
[testenv]
10-
whitelist_externals = make
11+
allowlist_externals = make
1112
deps=
1213
django22: Django>=2.2,<2.3
1314
django30: Django>=3.0b1,<3.1
1415
django31: Django>=3.1,<3.2
1516
django32: Django>=3.2,<4.0
1617
django40: Django>=4.0,<4.1
18+
django41: Django>=4.1,<4.2
1719
commands = make test
1820

1921
[testenv:checks]
2022
basepython = python3.7
21-
passenv = TOXENV CI
22-
whitelist_externals = make
23+
allowlist_externals = make
2324
deps =
2425
Django>=2.2,<2.3
2526
coverage==4.5.2

0 commit comments

Comments
 (0)