Skip to content

Commit 57ae280

Browse files
authored
Merge pull request #159 from django-commons/auto
Upgrade minimum enum_properties version to 2.5.1
2 parents 906fdab + 2a4868a commit 57ae280

File tree

7 files changed

+586
-821
lines changed

7 files changed

+586
-821
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ jobs:
4949
psycopg-version: ['psycopg2', 'psycopg3']
5050
django-version:
5151
- '4.2' # LTS April 2026
52-
- '5.1' # December 2025
5352
- '5.2' # LTS April 2028
5453
- '6.0' # April 2027
5554
exclude:
@@ -62,18 +61,13 @@ jobs:
6261
- postgres-version: '12'
6362
psycopg-version: 'psycopg3'
6463

65-
- postgres-version: '12'
66-
django-version: '5.1'
67-
6864
- postgres-version: '12'
6965
django-version: '5.2'
7066

7167
# https://github.com/psycopg/psycopg2/pull/1695
7268
- python-version: '3.13'
7369
psycopg-version: 'psycopg2'
7470

75-
- python-version: '3.14'
76-
django-version: '5.1'
7771
# https://github.com/psycopg/psycopg2/pull/1695
7872
- python-version: '3.14'
7973
psycopg-version: 'psycopg2'
@@ -520,8 +514,8 @@ jobs:
520514
python-version: ['3.10', '3.12', '3.14']
521515
django-version:
522516
- '4.2' # LTS April 2026
523-
- '5.2' # LTS April 2028
524-
- '6.0' # April 2027
517+
- '5.2.10' # LTS April 2028
518+
- '6.0.1' # April 2027
525519
oracle-version:
526520
- 'oracle-xe:21'
527521
- 'oracle-free:latest'
@@ -532,20 +526,20 @@ jobs:
532526
django-version: '4.2'
533527

534528
- python-version: '3.10'
535-
django-version: '5.2'
529+
django-version: '5.2.10'
536530
- python-version: '3.14'
537-
django-version: '5.2'
531+
django-version: '5.2.10'
538532

539533
- python-version: '3.10'
540-
django-version: '6.0'
534+
django-version: '6.0.1'
541535
- python-version: '3.12'
542-
django-version: '6.0'
536+
django-version: '6.0.1'
543537

544538
- django-version: '4.2'
545539
oracle-version: 'oracle-free:latest'
546-
- django-version: '5.2'
540+
- django-version: '5.2.10'
547541
oracle-version: 'oracle-xe:21'
548-
- django-version: '6.0'
542+
- django-version: '6.0.1'
549543
oracle-version: 'oracle-xe:21'
550544

551545
services:

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ validate_version VERSION:
268268
assert raw_version == django_enum.__version__
269269
print(raw_version)
270270

271-
# issue a relase for the given semver string (e.g. 2.1.0)
271+
# issue a release for the given semver string (e.g. 2.1.0)
272272
release VERSION:
273273
@just validate_version v{{ VERSION }}
274274
git tag -s v{{ VERSION }} -m "{{ VERSION }} Release"

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ classifiers = [
2323
"Topic :: Software Development :: Libraries :: Python Modules",
2424
"Development Status :: 5 - Production/Stable",
2525
"Framework :: Django :: 4.2",
26-
"Framework :: Django :: 5.1",
2726
"Framework :: Django :: 5.2",
2827
"Framework :: Django :: 6.0",
2928
"Intended Audience :: Developers",
@@ -59,8 +58,7 @@ packages = ["src/django_enum"]
5958

6059
[project.optional-dependencies]
6160
properties = [
62-
"enum-properties>=2.3.0; python_version < '3.14'",
63-
"enum-properties>=2.4.0; python_version >= '3.14'",
61+
"enum-properties>=2.5.1"
6462
]
6563
filters = ["django-filter>=21"]
6664
rest = ["djangorestframework>=3.9,<4.0"]
@@ -100,7 +98,7 @@ dev = [
10098
"pytest-env>=1.1.5",
10199
"pytest-playwright>=0.7.0",
102100
"python-dateutil>=2.9.0.post0",
103-
"ruff>=0.9.7",
101+
"ruff>=0.15.0",
104102
"tomlkit>=0.13.2",
105103
"tqdm>=4.67.1",
106104
"types-pyyaml>=6.0.12.20241230",
@@ -187,6 +185,7 @@ exclude = [
187185
"examples",
188186
"plot_benchmarks.py"
189187
]
188+
target-version = "py310"
190189

191190
[tool.ruff.lint]
192191
exclude = ["tests/**/*"]

src/django_enum/choices.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __hash__(self):
8989
return DjangoTextChoices.__hash__(self)
9090

9191

92-
class IntegerChoices(
92+
class IntegerChoices( # type: ignore[metaclass]
9393
DjangoSymmetricMixin, DjangoIntegerChoices, metaclass=DjangoEnumPropertiesMeta
9494
):
9595
"""
@@ -101,7 +101,7 @@ def __hash__(self):
101101
return DjangoIntegerChoices.__hash__(self)
102102

103103

104-
class FloatChoices(
104+
class FloatChoices( # type: ignore[metaclass]
105105
DjangoSymmetricMixin, float, Choices, metaclass=DjangoEnumPropertiesMeta
106106
):
107107
"""

tests/test_auto.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import pytest
2+
3+
pytest.importorskip("enum_properties")
4+
5+
import sys
6+
from django.test import TestCase
7+
from django_enum.choices import TextChoices
8+
from enum import auto
9+
10+
11+
@pytest.mark.skipif(sys.version_info < (3, 11), reason="Requires Python 3.11 or higher")
12+
class TestAutoWithChoices(TestCase):
13+
def test_auto_with_choices(self):
14+
15+
class MyTextChoices(TextChoices):
16+
custom_value: str
17+
18+
FOO = auto(), "FOO Label", "foo123"
19+
BAR = auto(), "BAR Label", "bar123"
20+
21+
self.assertEqual(MyTextChoices.FOO.value, "FOO")
22+
self.assertEqual(MyTextChoices.BAR.value, "BAR")
23+
24+
self.assertEqual(MyTextChoices.FOO.label, "FOO Label")
25+
self.assertEqual(MyTextChoices.BAR.label, "BAR Label")
26+
27+
self.assertEqual(MyTextChoices.FOO.custom_value, "foo123")
28+
self.assertEqual(MyTextChoices.BAR.custom_value, "bar123")
29+
30+
class MyTextChoicesAutoOverride(TextChoices):
31+
def _generate_next_value_(name, start, count, last_values):
32+
return name.title() * 2
33+
34+
custom_value: str
35+
36+
FOO = auto(), "FOO Label", "foo123"
37+
BAR = auto(), "BAR Label", "bar123"
38+
39+
self.assertEqual(MyTextChoicesAutoOverride.FOO.value, "FooFoo")
40+
self.assertEqual(MyTextChoicesAutoOverride.BAR.value, "BarBar")
41+
42+
self.assertEqual(MyTextChoicesAutoOverride.FOO.label, "FOO Label")
43+
self.assertEqual(MyTextChoicesAutoOverride.BAR.label, "BAR Label")
44+
45+
self.assertEqual(MyTextChoicesAutoOverride.FOO.custom_value, "foo123")
46+
self.assertEqual(MyTextChoicesAutoOverride.BAR.custom_value, "bar123")

0 commit comments

Comments
 (0)