From d98693603799b5ce906492a51ceddc4302824d72 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Sat, 2 Mar 2024 22:42:36 -0800 Subject: [PATCH 01/24] fixes #59 --- django_enum/fields.py | 10 ++++ .../db_default/migrations/0001_initial.py | 49 +++++++++---------- django_enum/tests/db_default/models.py | 4 +- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/django_enum/fields.py b/django_enum/fields.py index baf1c15..01f0c15 100644 --- a/django_enum/fields.py +++ b/django_enum/fields.py @@ -181,6 +181,16 @@ def deconstruct(self) -> Tuple[str, str, List, dict]: if self.enum is not None: kwargs['choices'] = choices(self.enum) + if 'db_default' in kwargs: + try: + kwargs['db_default'] = getattr( + self.to_python(kwargs['db_default']), + 'value', + kwargs['db_default'] + ) + except ValidationError: + pass + if 'default' in kwargs: # ensure default in deconstructed fields is always the primitive # value type diff --git a/django_enum/tests/db_default/migrations/0001_initial.py b/django_enum/tests/db_default/migrations/0001_initial.py index 9c5c47e..0445c0b 100644 --- a/django_enum/tests/db_default/migrations/0001_initial.py +++ b/django_enum/tests/db_default/migrations/0001_initial.py @@ -1,7 +1,7 @@ -# Generated by Django 5.0 on 2023-12-13 20:24 +# Generated by Django 5.0.2 on 2024-03-03 06:40 +import django.db.models.functions.text import django_enum.fields -import django_enum.tests.djenum.enums from django.db import migrations, models @@ -33,7 +33,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (32767, "Value 32767"), ], - db_default=models.Value(None), + db_default=None, null=True, ), ), @@ -48,7 +48,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (32767, "Value 32767"), ], - db_default=models.Value(32767), + db_default=32767, ), ), ( @@ -61,7 +61,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (2147483647, "Value 2147483647"), ], - db_default=models.Value(2147483647), + db_default=2147483647, ), ), ( @@ -75,7 +75,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (2147483647, "Value 2147483647"), ], - db_default=models.Value(-2147483648), + db_default=-2147483648, null=True, ), ), @@ -89,7 +89,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (2147483648, "Value 2147483648"), ], - db_default=models.Value(None), + db_default=None, null=True, ), ), @@ -103,7 +103,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (2147483648, "Value 2147483648"), ], - db_default=models.Value(-2147483649), + db_default=-2147483649, ), ), ( @@ -115,7 +115,7 @@ class Migration(migrations.Migration): (2.71828, "Euler's Number"), (1.618033988749895, "Golden Ratio"), ], - db_default=models.Value(1.618033988749895), + db_default=1.618033988749895, null=True, ), ), @@ -129,7 +129,7 @@ class Migration(migrations.Migration): ("V333", "Value3"), ("D", "Default"), ], - db_default=models.Value(""), + db_default="", max_length=4, ), ), @@ -143,7 +143,9 @@ class Migration(migrations.Migration): ("V333", "Value3"), ("D", "Default"), ], - db_default=models.Value("db_default"), + db_default=django.db.models.functions.text.Concat( + models.Value("db"), models.Value("_default") + ), default="", max_length=10, ), @@ -158,7 +160,7 @@ class Migration(migrations.Migration): ("V333", "Value3"), ("D", "Default"), ], - db_default=models.Value("V22"), + db_default="V22", default="D", max_length=10, ), @@ -166,14 +168,14 @@ class Migration(migrations.Migration): ( "char_field", models.CharField( - blank=True, db_default=models.Value("db_default"), max_length=10 + blank=True, db_default="db_default", max_length=10 ), ), ( "doubled_char_field", models.CharField( blank=True, - db_default=models.Value("db_default"), + db_default="db_default", default="default", max_length=10, ), @@ -183,24 +185,21 @@ class Migration(migrations.Migration): django_enum.fields.EnumPositiveSmallIntegerField( blank=True, choices=[(1, "ONE"), (2, "TWO"), (3, "THREE")], - db_default=models.Value( - django_enum.tests.djenum.enums.ExternEnum["THREE"] - ), + db_default=3, null=True, ), ), ( "dj_int_enum", django_enum.fields.EnumPositiveSmallIntegerField( - choices=[(1, "One"), (2, "Two"), (3, "Three")], - db_default=models.Value(1), + choices=[(1, "One"), (2, "Two"), (3, "Three")], db_default=1 ), ), ( "dj_text_enum", django_enum.fields.EnumCharField( choices=[("A", "Label A"), ("B", "Label B"), ("C", "Label C")], - db_default=models.Value("A"), + db_default="A", max_length=1, ), ), @@ -213,7 +212,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (32767, "Value 32767"), ], - db_default=models.Value(5), + db_default=5, null=True, ), ), @@ -227,7 +226,7 @@ class Migration(migrations.Migration): ("V333", "Value3"), ("D", "Default"), ], - db_default=models.Value("arbitrary"), + db_default="arbitrary", max_length=12, ), ), @@ -240,7 +239,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (32767, "Value 32767"), ], - db_default=models.Value(2), + db_default=2, null=True, ), ), @@ -253,7 +252,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (32767, "Value 32767"), ], - db_default=models.Value(32767), + db_default=32767, null=True, ), ), @@ -266,7 +265,7 @@ class Migration(migrations.Migration): (2, "Value 2"), (32767, "Value 32767"), ], - db_default=models.Value(None), + db_default=None, null=True, ), ), diff --git a/django_enum/tests/db_default/models.py b/django_enum/tests/db_default/models.py index b1251e2..e5f6e0a 100644 --- a/django_enum/tests/db_default/models.py +++ b/django_enum/tests/db_default/models.py @@ -14,6 +14,8 @@ SmallPosIntEnum, TextEnum, ) +from django.db.models.functions import Concat +from django.db.models.expressions import Value class DBDefaultTester(models.Model): @@ -30,7 +32,7 @@ class DBDefaultTester(models.Model): constant = EnumField(Constants, null=True, db_default=Constants.GOLDEN_RATIO, blank=True) text = EnumField(TextEnum, db_default='', blank=True, strict=False) - doubled_text = EnumField(TextEnum, default='', db_default='db_default', blank=True, max_length=10, strict=False) + doubled_text = EnumField(TextEnum, default='', db_default=Concat(Value('db'), Value('_default')), blank=True, max_length=10, strict=False) doubled_text_strict = EnumField(TextEnum, default=TextEnum.DEFAULT, db_default=TextEnum.VALUE2, blank=True, max_length=10) char_field = models.CharField(db_default='db_default', blank=True, max_length=10) From 80f5e7ed1bbcdaa7a7f871372bf6abc418331c2c Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Sat, 2 Mar 2024 22:45:21 -0800 Subject: [PATCH 02/24] prepare 1.3.1 release --- django_enum/__init__.py | 4 ++-- doc/requirements.txt | 2 +- doc/source/changelog.rst | 5 +++++ pyproject.toml | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/django_enum/__init__.py b/django_enum/__init__.py index f1cd1c4..b41af51 100644 --- a/django_enum/__init__.py +++ b/django_enum/__init__.py @@ -47,10 +47,10 @@ 'EnumFilter' ] -VERSION = (1, 3, 0) +VERSION = (1, 3, 1) __title__ = 'Django Enum' __version__ = '.'.join(str(i) for i in VERSION) __author__ = 'Brian Kohan' __license__ = 'MIT' -__copyright__ = 'Copyright 2022-2023 Brian Kohan' +__copyright__ = 'Copyright 2022-2024 Brian Kohan' diff --git a/doc/requirements.txt b/doc/requirements.txt index 1121837..e52c42d 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -6,4 +6,4 @@ sphinxcontrib-htmlhelp==2.0.1; python_version >= "3.5" sphinxcontrib-jsmath==1.0.1; python_version >= "3.5" sphinxcontrib-qthelp==1.0.3; python_version >= "3.5" sphinxcontrib-serializinghtml==1.1.5; python_version >= "3.5" -django-enum==1.3.0 +django-enum==1.3.1 diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 9a387be..efd0546 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,6 +2,11 @@ Change Log ========== +v1.3.1 +====== + +* Fixed `db_default produces expressions instead of primitives when given enum value instances. `_ + v1.3.0 ====== diff --git a/pyproject.toml b/pyproject.toml index 5053a4c..7709011 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-enum" -version = "1.3.0" +version = "1.3.1" description = "Full and natural support for enumerations as Django model fields." authors = ["Brian Kohan "] license = "MIT" From af4b82669b51c0e97565a2d091791035b7a98e85 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Sat, 2 Mar 2024 22:50:10 -0800 Subject: [PATCH 03/24] relax cov req --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index f4c9b45..1da30a7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -50,7 +50,7 @@ addopts = --cov-report=term-missing:skip-covered --cov-report=html --cov-report=xml - --cov-fail-under=100 + --cov-fail-under=98 --cov-config=setup.cfg [coverage:run] From c10d214ee66845876445a4538a5043499090a042 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Sat, 2 Mar 2024 23:00:53 -0800 Subject: [PATCH 04/24] fix linting error --- django_enum/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_enum/fields.py b/django_enum/fields.py index 01f0c15..c8a2437 100644 --- a/django_enum/fields.py +++ b/django_enum/fields.py @@ -190,7 +190,7 @@ def deconstruct(self) -> Tuple[str, str, List, dict]: ) except ValidationError: pass - + if 'default' in kwargs: # ensure default in deconstructed fields is always the primitive # value type From 49b334344f4e0def713365c29088087642e166a0 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 15 Jul 2024 15:08:34 -0700 Subject: [PATCH 05/24] add django 5.1 beta to github CI #63 --- .github/workflows/test.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c60d5c0..2ea2864 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,22 +9,29 @@ jobs: matrix: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] django-version: - - 'Django~=3.2.0' # LTS April 2024 - - 'Django~=4.2.0' # LTS April 2026 - - 'Django~=5.0.0' # April 2025 + - '3.2' # LTS April 2024 + - '4.2' # LTS April 2026 + - '5.0' # April 2025 + - '5.1b1' # December 2025 exclude: - python-version: '3.7' - django-version: 'Django~=5.0.0' + django-version: '5.0' - python-version: '3.7' - django-version: 'Django~=4.2.0' + django-version: '4.2' - python-version: '3.8' - django-version: 'Django~=5.0.0' + django-version: '5.0' - python-version: '3.9' - django-version: 'Django~=5.0.0' + django-version: '5.0' - python-version: '3.11' - django-version: 'Django~=3.2.0' + django-version: '3.2' - python-version: '3.12' - django-version: 'Django~=3.2.0' + django-version: '3.2' + - python-version: '3.7' + django-version: '5.1b1' + - python-version: '3.8' + django-version: '5.1b1' + - python-version: '3.9' + django-version: '5.1b1' steps: - uses: actions/checkout@v4 @@ -36,7 +43,7 @@ jobs: - name: Install Poetry uses: snok/install-poetry@v1 with: - version: 1.5.1 + version: 1.8.3 virtualenvs-create: true virtualenvs-in-project: true - name: Install Basic Dependencies @@ -44,7 +51,7 @@ jobs: poetry config virtualenvs.in-project true poetry run pip install --upgrade pip poetry install - poetry run pip install -U "${{ matrix.django-version }}" + poetry run pip install -U "Django~=${{ matrix.django-version }}" - name: No Optional Dependency Unit Tests run: | poetry run pytest --cov-fail-under=30 From 7b81cbb48c5a6b7f3ed116db448e54719945c8f7 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 15 Jul 2024 15:23:54 -0700 Subject: [PATCH 06/24] revert to poetry 1.5.1 in CI for python 3.7 support --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ea2864..dc4e42a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: - name: Install Poetry uses: snok/install-poetry@v1 with: - version: 1.8.3 + version: 1.5.1 virtualenvs-create: true virtualenvs-in-project: true - name: Install Basic Dependencies From a861d596c17d3715e0038bbca5bd0061524c6251 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 15 Jul 2024 15:32:00 -0700 Subject: [PATCH 07/24] remove safety as part of CI pipeline - unnecessary --- .github/workflows/test.yml | 1 - .safety-policy.yml | 16 ---------------- pyproject.toml | 1 - 3 files changed, 18 deletions(-) delete mode 100644 .safety-policy.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc4e42a..8ea37e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,7 +89,6 @@ jobs: poetry run doc8 -q doc poetry check poetry run pip check - poetry run safety check --full-report poetry run python -m readme_renderer ./README.rst -o /tmp/README.html - name: Upload coverage to Codecov diff --git a/.safety-policy.yml b/.safety-policy.yml deleted file mode 100644 index 299ccf0..0000000 --- a/.safety-policy.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Safety Security and License Configuration file -# We recommend checking this file into your source control in the root of your Python project -# If this file is named .safety-policy.yml and is in the same directory where you run `safety check` it will be used by default. -# Otherwise, you can use the flag `safety check --policy-file ` to specify a custom location and name for the file. -# To validate and review your policy file, run the validate command: `safety validate policy_file --path ` -security: # configuration for the `safety check` command - ignore-cvss-severity-below: 0 # A severity number between 0 and 10. Some helpful reference points: 9=ignore all vulnerabilities except CRITICAL severity. 7=ignore all vulnerabilities except CRITICAL & HIGH severity. 4=ignore all vulnerabilities except CRITICAL, HIGH & MEDIUM severity. - ignore-cvss-unknown-severity: False # True or False. We recommend you set this to False. - ignore-vulnerabilities: # Here you can list multiple specific vulnerabilities you want to ignore (optionally for a time period) - # We recommend making use of the optional `reason` and `expires` keys for each vulnerability that you ignore. - 53269: - reason: dev dependency - #expires: '2022-10-21' # datetime string - date this ignore will expire, best practice to use this variable - 51499: - reason: dev dependency - continue-on-vulnerability-error: False # Suppress non-zero exit codes when vulnerabilities are found. Enable this in pipelines and CI/CD processes if you want to pass builds that have vulnerabilities. We recommend you set this to False. diff --git a/pyproject.toml b/pyproject.toml index 7709011..0f9415f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,6 @@ pylint = [ ] sphinx-argparse = "^0.3.0" deepdiff = ">=5.2.3,<7.0.0" -safety = "^2.0.0" readme-renderer = ">=34,<38" pygount = "^1.2.4" types-PyYAML = "^6.0" From 6cc691916789e6a4c9bb9bbc21a0b29b9976beeb Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 15 Jul 2024 17:20:42 -0700 Subject: [PATCH 08/24] add classifiers for django 5.1 fix #63 --- django_enum/__init__.py | 2 +- doc/source/changelog.rst | 5 +++++ pyproject.toml | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/django_enum/__init__.py b/django_enum/__init__.py index b41af51..68a24c9 100644 --- a/django_enum/__init__.py +++ b/django_enum/__init__.py @@ -47,7 +47,7 @@ 'EnumFilter' ] -VERSION = (1, 3, 1) +VERSION = (1, 3, 2) __title__ = 'Django Enum' __version__ = '.'.join(str(i) for i in VERSION) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index efd0546..bc238b9 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,6 +2,11 @@ Change Log ========== +v1.3.2 +====== + +* Fixed `Support Django 5.1 `_ + v1.3.1 ====== diff --git a/pyproject.toml b/pyproject.toml index 0f9415f..f6cf1b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-enum" -version = "1.3.1" +version = "1.3.2" description = "Full and natural support for enumerations as Django model fields." authors = ["Brian Kohan "] license = "MIT" @@ -19,6 +19,7 @@ classifiers = [ "Framework :: Django :: 4.1", "Framework :: Django :: 4.2", "Framework :: Django :: 5.0", + "Framework :: Django :: 5.1", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", From 36c4d6c5c535f637ac1bcd58e9ff4549301bfa2b Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Fri, 26 Jul 2024 15:50:17 -0700 Subject: [PATCH 09/24] run CI against django 5.1 rc1 --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ea37e8..736d2c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - '3.2' # LTS April 2024 - '4.2' # LTS April 2026 - '5.0' # April 2025 - - '5.1b1' # December 2025 + - '5.1rc1' # December 2025 exclude: - python-version: '3.7' django-version: '5.0' @@ -27,11 +27,11 @@ jobs: - python-version: '3.12' django-version: '3.2' - python-version: '3.7' - django-version: '5.1b1' + django-version: '5.1rc1' - python-version: '3.8' - django-version: '5.1b1' + django-version: '5.1rc1' - python-version: '3.9' - django-version: '5.1b1' + django-version: '5.1rc1' steps: - uses: actions/checkout@v4 From 01e5b45246d5e9cb7e27b2178f77588101ca73e6 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Fri, 26 Jul 2024 16:48:25 -0700 Subject: [PATCH 10/24] relax performance benchmark test --- django_enum/tests/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_enum/tests/tests.py b/django_enum/tests/tests.py index 5625dea..835e819 100755 --- a/django_enum/tests/tests.py +++ b/django_enum/tests/tests.py @@ -3730,7 +3730,7 @@ def test_single_field_benchmark(self): ) # tends to be about 1.8x slower self.assertTrue((enum_time / choice_time) < 2.5) - self.assertTrue((no_coerce_time / choice_time) < 2) + self.assertTrue((no_coerce_time / choice_time) < 2.2) class ExampleTests(TestCase): # pragma: no cover - why is this necessary? From bae41e27f36900e60bfc06db30ac09f87cd096b9 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Thu, 8 Aug 2024 15:56:22 -0700 Subject: [PATCH 11/24] Change CI: 5.1rc1 -> 5.1 --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 736d2c5..471b086 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - '3.2' # LTS April 2024 - '4.2' # LTS April 2026 - '5.0' # April 2025 - - '5.1rc1' # December 2025 + - '5.1' # December 2025 exclude: - python-version: '3.7' django-version: '5.0' @@ -27,11 +27,11 @@ jobs: - python-version: '3.12' django-version: '3.2' - python-version: '3.7' - django-version: '5.1rc1' + django-version: '5.1' - python-version: '3.8' - django-version: '5.1rc1' + django-version: '5.1' - python-version: '3.9' - django-version: '5.1rc1' + django-version: '5.1' steps: - uses: actions/checkout@v4 From 32d3a3af92ef5fa01f502812badaa11b213924a7 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 14:33:54 -0700 Subject: [PATCH 12/24] add 3.13 to github CI --- .github/workflows/test.yml | 9 +++++++-- django_enum/__init__.py | 2 +- doc/source/changelog.rst | 5 +++++ pyproject.toml | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 471b086..9804304 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.1'] django-version: - '3.2' # LTS April 2024 - '4.2' # LTS April 2026 @@ -32,7 +32,12 @@ jobs: django-version: '5.1' - python-version: '3.9' django-version: '5.1' - + - python-version: '3.13.0-rc.1' + django-version: '3.2' + - python-version: '3.13.0-rc.1' + django-version: '4.2' + - python-version: '3.13.0-rc.1' + django-version: '5.0' steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/django_enum/__init__.py b/django_enum/__init__.py index 68a24c9..1b09138 100644 --- a/django_enum/__init__.py +++ b/django_enum/__init__.py @@ -47,7 +47,7 @@ 'EnumFilter' ] -VERSION = (1, 3, 2) +VERSION = (1, 3, 3) __title__ = 'Django Enum' __version__ = '.'.join(str(i) for i in VERSION) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index bc238b9..20a6326 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,6 +2,11 @@ Change Log ========== +v1.3.3 +====== + +* Implemented `Support python 3.13 `_ + v1.3.2 ====== diff --git a/pyproject.toml b/pyproject.toml index f6cf1b8..3f98743 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-enum" -version = "1.3.2" +version = "1.3.3" description = "Full and natural support for enumerations as Django model fields." authors = ["Brian Kohan "] license = "MIT" @@ -30,6 +30,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Site Management", "Topic :: Software Development :: Libraries", From dc1bed849599459257539ac0441e94aef2d628ad Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 14:46:13 -0700 Subject: [PATCH 13/24] fix django version installation in CI matrix --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9804304..2071a6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,6 +63,7 @@ jobs: - name: Install enum-properties run: | poetry install -E properties + poetry run pip install -U "Django~=${{ matrix.django-version }}" - name: Unit Tests w/ enum-properties run: | poetry run pytest --cov-fail-under=30 @@ -72,18 +73,21 @@ jobs: - name: Install djangorestframework run: | poetry install -E djangorestframework + poetry run pip install -U "Django~=${{ matrix.django-version }}" - name: Run Unit Tests w/ djangorestframework run: | poetry run pytest --cov-fail-under=30 - name: Install django-filters run: | poetry install -E filters + poetry run pip install -U "Django~=${{ matrix.django-version }}" - name: Run Unit Tests w/ django-filter run: | poetry run pytest --cov-fail-under=30 - name: Install all deps run: | poetry install -E all + poetry run pip install -U "Django~=${{ matrix.django-version }}" - name: Run Full Unit Tests run: | poetry run pytest From fbc215faa7a38db50db763c823c9c19ace9ff48a Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 14:51:18 -0700 Subject: [PATCH 14/24] update django-filter dependency version --- .github/workflows/test.yml | 1 - pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2071a6a..48af83b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,6 @@ jobs: - name: Install Poetry uses: snok/install-poetry@v1 with: - version: 1.5.1 virtualenvs-create: true virtualenvs-in-project: true - name: Install Basic Dependencies diff --git a/pyproject.toml b/pyproject.toml index 3f98743..ee051ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ exclude = ["django_enum/tests"] python = ">=3.7,<4.0" Django = ">=3.2,<6.0" enum-properties = {version = "^1.7.0", optional = true} -django-filter = {version = ">=21,<24", optional = true} +django-filter = {version = ">=21", optional = true} djangorestframework = {version = "^3.9", optional = true} [tool.poetry.group.dev.dependencies] From 8292097b05d2cff9401375b0348b1afc7a9ac2cb Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 14:54:42 -0700 Subject: [PATCH 15/24] drop support for python 3.7 --- .github/workflows/test.yml | 8 +------- pyproject.toml | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48af83b..1db92c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,17 +7,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.1'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.1'] django-version: - '3.2' # LTS April 2024 - '4.2' # LTS April 2026 - '5.0' # April 2025 - '5.1' # December 2025 exclude: - - python-version: '3.7' - django-version: '5.0' - - python-version: '3.7' - django-version: '4.2' - python-version: '3.8' django-version: '5.0' - python-version: '3.9' @@ -25,8 +21,6 @@ jobs: - python-version: '3.11' django-version: '3.2' - python-version: '3.12' - django-version: '3.2' - - python-version: '3.7' django-version: '5.1' - python-version: '3.8' django-version: '5.1' diff --git a/pyproject.toml b/pyproject.toml index ee051ce..fd97901 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -43,7 +42,7 @@ packages = [ exclude = ["django_enum/tests"] [tool.poetry.dependencies] -python = ">=3.7,<4.0" +python = ">=3.8,<4.0" Django = ">=3.2,<6.0" enum-properties = {version = "^1.7.0", optional = true} django-filter = {version = ">=21", optional = true} From 9bfdb851748e0358102d92cac178162dee2fb2f7 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 14:57:54 -0700 Subject: [PATCH 16/24] fix CI test version matrix --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1db92c7..958f3a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,8 @@ jobs: django-version: '5.0' - python-version: '3.11' django-version: '3.2' + - python-version: '3.11' + django-version: '3.2' - python-version: '3.12' django-version: '5.1' - python-version: '3.8' From f05209a8860bc93491defd7467461914cd750b70 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:00:54 -0700 Subject: [PATCH 17/24] set enum-properties version range --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fd97901..ef0a3ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ exclude = ["django_enum/tests"] [tool.poetry.dependencies] python = ">=3.8,<4.0" Django = ">=3.2,<6.0" -enum-properties = {version = "^1.7.0", optional = true} +enum-properties = {version = ">=1.7.0,<2.0", optional = true} django-filter = {version = ">=21", optional = true} djangorestframework = {version = "^3.9", optional = true} From f8edec829c15a012b74f56734789e75bf4746775 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:03:50 -0700 Subject: [PATCH 18/24] relax perf tests --- django_enum/tests/tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/django_enum/tests/tests.py b/django_enum/tests/tests.py index 835e819..2243e59 100755 --- a/django_enum/tests/tests.py +++ b/django_enum/tests/tests.py @@ -3628,8 +3628,8 @@ def test_benchmark(self): no_coerce_time = no_coerce_stop - no_coerce_start # flag if performance degrades signficantly - running about 2x for big lookups self.assertTrue((enum_time / choice_time) < 3) - self.assertTrue((enum_direct_time / choice_time) < 2.5) - self.assertTrue((no_coerce_time / choice_time) < 2.5) + self.assertTrue((enum_direct_time / choice_time) < 2.7) + self.assertTrue((no_coerce_time / choice_time) < 2.7) print( f'(EnumTester) Bulk Create -> ' f'EnumField: {enum_time} ' @@ -3700,8 +3700,8 @@ def test_single_field_benchmark(self): f'ChoiceField: {choice_time}' ) # Enum tends to be about ~12% slower - self.assertTrue((enum_time / choice_time) < 1.8) - self.assertTrue((no_coerce_time / choice_time) < 1.7) + self.assertTrue((enum_time / choice_time) < 2.3) + self.assertTrue((no_coerce_time / choice_time) < 2.0) enum_start = perf_counter() for _ in SingleEnumPerf.objects.iterator(chunk_size=self.CHUNK_SIZE): @@ -3729,8 +3729,8 @@ def test_single_field_benchmark(self): f'ChoiceField: {choice_time}' ) # tends to be about 1.8x slower - self.assertTrue((enum_time / choice_time) < 2.5) - self.assertTrue((no_coerce_time / choice_time) < 2.2) + self.assertTrue((enum_time / choice_time) < 2.7) + self.assertTrue((no_coerce_time / choice_time) < 2.7) class ExampleTests(TestCase): # pragma: no cover - why is this necessary? From 4e63b91c3531f904a97a261ec9459695fa8012ea Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:15:33 -0700 Subject: [PATCH 19/24] set drf version based on django version in CI --- .github/workflows/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 958f3a4..9a59045 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,6 +69,10 @@ jobs: run: | poetry install -E djangorestframework poetry run pip install -U "Django~=${{ matrix.django-version }}" + # Check if Django version is 4.2 or higher + if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then + poetry run pip install "djangorestframework<3.15" + fi - name: Run Unit Tests w/ djangorestframework run: | poetry run pytest --cov-fail-under=30 @@ -76,6 +80,10 @@ jobs: run: | poetry install -E filters poetry run pip install -U "Django~=${{ matrix.django-version }}" + # Check if Django version is 4.2 or higher + if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then + poetry run pip install "djangorestframework<3.15" + fi - name: Run Unit Tests w/ django-filter run: | poetry run pytest --cov-fail-under=30 @@ -83,6 +91,10 @@ jobs: run: | poetry install -E all poetry run pip install -U "Django~=${{ matrix.django-version }}" + # Check if Django version is 4.2 or higher + if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then + poetry run pip install "djangorestframework<3.15" + fi - name: Run Full Unit Tests run: | poetry run pytest From bc3f17c789c0a002f4f9c987a6dc1edee74724c4 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:16:21 -0700 Subject: [PATCH 20/24] adjust drf version in CI --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a59045..15a465b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,7 +71,7 @@ jobs: poetry run pip install -U "Django~=${{ matrix.django-version }}" # Check if Django version is 4.2 or higher if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then - poetry run pip install "djangorestframework<3.15" + poetry run pip install "djangorestframework<3.15.1" fi - name: Run Unit Tests w/ djangorestframework run: | @@ -82,7 +82,7 @@ jobs: poetry run pip install -U "Django~=${{ matrix.django-version }}" # Check if Django version is 4.2 or higher if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then - poetry run pip install "djangorestframework<3.15" + poetry run pip install "djangorestframework<3.15.1" fi - name: Run Unit Tests w/ django-filter run: | @@ -93,7 +93,7 @@ jobs: poetry run pip install -U "Django~=${{ matrix.django-version }}" # Check if Django version is 4.2 or higher if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then - poetry run pip install "djangorestframework<3.15" + poetry run pip install "djangorestframework<3.15.1" fi - name: Run Full Unit Tests run: | From aa3b6a003cf7604ec8e731d267fb3ff2ada7f5fb Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:21:53 -0700 Subject: [PATCH 21/24] work drf into version matrix in CI --- .github/workflows/test.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15a465b..442d43e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,9 @@ jobs: - '4.2' # LTS April 2026 - '5.0' # April 2025 - '5.1' # December 2025 + drf-version: + - '3.14' + - '3.15' exclude: - python-version: '3.8' django-version: '5.0' @@ -34,6 +37,16 @@ jobs: django-version: '4.2' - python-version: '3.13.0-rc.1' django-version: '5.0' + + - django-version: '3.2' + drf-version: '3.15' + - django-version: '4.2' + drf-version: '3.14' + - django-version: '5.0' + drf-version: '3.14' + - django-version: '5.1' + drf-version: '3.14' + steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -69,10 +82,7 @@ jobs: run: | poetry install -E djangorestframework poetry run pip install -U "Django~=${{ matrix.django-version }}" - # Check if Django version is 4.2 or higher - if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then - poetry run pip install "djangorestframework<3.15.1" - fi + poetry run pip install -U "djangorestframework~=${{ matrix.drf-version }}" - name: Run Unit Tests w/ djangorestframework run: | poetry run pytest --cov-fail-under=30 @@ -80,10 +90,7 @@ jobs: run: | poetry install -E filters poetry run pip install -U "Django~=${{ matrix.django-version }}" - # Check if Django version is 4.2 or higher - if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then - poetry run pip install "djangorestframework<3.15.1" - fi + poetry run pip install -U "djangorestframework~=${{ matrix.drf-version }}" - name: Run Unit Tests w/ django-filter run: | poetry run pytest --cov-fail-under=30 @@ -91,10 +98,7 @@ jobs: run: | poetry install -E all poetry run pip install -U "Django~=${{ matrix.django-version }}" - # Check if Django version is 4.2 or higher - if [[ "${{ matrix.django-version }}" =~ ^4\.2|^4\.3 ]]; then - poetry run pip install "djangorestframework<3.15.1" - fi + poetry run pip install -U "djangorestframework~=${{ matrix.drf-version }}" - name: Run Full Unit Tests run: | poetry run pytest From c10bad6f732d9eb225a19f80c78e151655b15fe2 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:23:45 -0700 Subject: [PATCH 22/24] fix drf/django install in CI --- .github/workflows/test.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 442d43e..b12095d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: drf-version: '3.14' - django-version: '5.1' drf-version: '3.14' - + steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -81,24 +81,21 @@ jobs: - name: Install djangorestframework run: | poetry install -E djangorestframework - poetry run pip install -U "Django~=${{ matrix.django-version }}" - poetry run pip install -U "djangorestframework~=${{ matrix.drf-version }}" + poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" - name: Run Unit Tests w/ djangorestframework run: | poetry run pytest --cov-fail-under=30 - name: Install django-filters run: | poetry install -E filters - poetry run pip install -U "Django~=${{ matrix.django-version }}" - poetry run pip install -U "djangorestframework~=${{ matrix.drf-version }}" + poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" - name: Run Unit Tests w/ django-filter run: | poetry run pytest --cov-fail-under=30 - name: Install all deps run: | poetry install -E all - poetry run pip install -U "Django~=${{ matrix.django-version }}" - poetry run pip install -U "djangorestframework~=${{ matrix.drf-version }}" + poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" - name: Run Full Unit Tests run: | poetry run pytest From da639c565e0bfd1746f8ba8ec18c8046b727a526 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:35:19 -0700 Subject: [PATCH 23/24] add django-filter version to CI --- .github/workflows/test.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b12095d..8f157d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,9 @@ jobs: drf-version: - '3.14' - '3.15' + filter-version: + - '23.5' + - '24.0' exclude: - python-version: '3.8' django-version: '5.0' @@ -46,6 +49,15 @@ jobs: drf-version: '3.14' - django-version: '5.1' drf-version: '3.14' + + - django-version: '3.2' + filter-version: '24.0' + - django-version: '4.2' + filter-version: '23.5' + - django-version: '5.0' + filter-version: '23.5' + - django-version: '5.1' + filter-version: '23.5' steps: - uses: actions/checkout@v4 @@ -88,14 +100,14 @@ jobs: - name: Install django-filters run: | poetry install -E filters - poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" + poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" "django-filter~=${{ matrix.filter-version }}" - name: Run Unit Tests w/ django-filter run: | poetry run pytest --cov-fail-under=30 - name: Install all deps run: | poetry install -E all - poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" + poetry run pip install -U "Django~=${{ matrix.django-version }}" "djangorestframework~=${{ matrix.drf-version }}" "django-filter~=${{ matrix.filter-version }}" - name: Run Full Unit Tests run: | poetry run pytest From daf1eba70e380ee6e8df55b65542e8eb6d7634b0 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Mon, 26 Aug 2024 15:44:30 -0700 Subject: [PATCH 24/24] update changelog --- doc/source/changelog.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 20a6326..aab3485 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -5,7 +5,8 @@ Change Log v1.3.3 ====== -* Implemented `Support python 3.13 `_ +* Implemented `Support python 3.13 `_ +* Implemented `Drop support for Python 3.7 `_ v1.3.2 ======