diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b095c41..5509eb7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,16 +13,16 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 - name: Install dependencies run: | python -m pip install --upgrade pip pip install tox - + - name: Run tox -e lint run: tox - env: + env: TOXENV: lint test: @@ -34,18 +34,20 @@ jobs: toxenv: - py36-dj22 - py36-dj32 - - py38-dj22 - - py38-dj32 + - py39-dj22 + - py39-dj32 + - py39-dj40 include: - toxenv: py36-dj22 python-version: 3.6 - toxenv: py36-dj32 python-version: 3.6 - - toxenv: py38-dj22 - python-version: 3.8 - - toxenv: py38-dj32 - python-version: 3.8 - + - toxenv: py39-dj22 + python-version: 3.9 + - toxenv: py39-dj32 + python-version: 3.9 + - toxenv: py39-dj40 + python-version: 3.9 steps: - uses: actions/checkout@v1 @@ -63,7 +65,7 @@ jobs: run: | tox coveralls - env: + env: TOXENV: ${{ matrix.toxenv }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 87524ee..236ccf8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Feature flags allow you to toggle functionality in both Django code and the Djan ## Dependencies - Python 3.6+ -- Django 2.2-3.2 +- Django 2.2-4.0 ## Installation @@ -39,7 +39,7 @@ pip install django-flags ## Documentation -https://cfpb.github.io/django-flags is the full documentation for Django-Flags, and includes how to get started, general usage, and an API reference. +https://cfpb.github.io/django-flags is the full documentation for Django-Flags, and includes how to get started, general usage, and an API reference. ## Getting help diff --git a/docs/releasenotes.md b/docs/releasenotes.md index 870eada..22e6ce9 100644 --- a/docs/releasenotes.md +++ b/docs/releasenotes.md @@ -1,5 +1,12 @@ # Release Notes +## 5.0.6 + +### What's new? + +- Added Django 4.0 support (thanks [@gregtap](https://github.com/gregtap)!) + + ## 5.0.5 ### What's new? @@ -131,7 +138,7 @@ ### What's new? - The template functions `flag_enabled` and `flag_disabled` in both [Django](/api/django) and [Jinja2](/api/jinja2) templates now support taking keyword arguments that could be used by [custom conditions](/api/conditions). -- Jinja2 template functions are now available via a Jinja2 extension that can be [included in `settings.py`](/api/jinja2). +- Jinja2 template functions are now available via a Jinja2 extension that can be [included in `settings.py`](/api/jinja2). - The optional `flags.middleware.FlagConditionsMiddleware` has been added to ensure that all feature flag checks throughout single request cycle use the same flag conditions. - Support for specifying the [source of feature flags in `settings.py`](/settings#flag_sources) has been added to allow further customization and the potential to limit flags to settings or database-only. - The "user" condition now supports custom user models. ([@callorico](https://github.com/callorico)) @@ -157,7 +164,7 @@ TEMPLATES = [ ], } }, -] +] ``` ## 3.0.2 diff --git a/flags/state.py b/flags/state.py index a41428c..cfb75b9 100644 --- a/flags/state.py +++ b/flags/state.py @@ -1,7 +1,6 @@ from django.apps import apps from django.core.exceptions import AppRegistryNotReady -from flags.models import FlagState from flags.sources import get_flags @@ -20,6 +19,8 @@ def _set_flag_state( flag_name, state, create_boolean_condition=True, request=None ): """A private function to set a boolean condition to the desired state""" + from flags.models import FlagState + flags = get_flags(request=request) flag = flags.get(flag_name) if flag is None: diff --git a/flags/tests/test_conditions_validators.py b/flags/tests/test_conditions_validators.py index aaa3ec1..3e0db48 100644 --- a/flags/tests/test_conditions_validators.py +++ b/flags/tests/test_conditions_validators.py @@ -1,3 +1,4 @@ +import django from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError from django.test import TestCase, override_settings @@ -87,8 +88,13 @@ class ValidateDateTestCase(TestCase): def test_invalid_date_strings(self): with self.assertRaises(ValidationError): validate_date("tomorrowish") - with self.assertRaises(ValidationError): - validate_date("2020-04-01") + + # Django 4.0 relies on Python 3.7+'s `datetime.fromisoformat()`, which + # handles this where the old regex did not. This is now valid when on + # Django 4.0+. See https://github.com/django/django/pull/14582 + if django.VERSION < (4, 0): + with self.assertRaises(ValidationError): + validate_date("2020-04-01") def test_valid_date_strings(self): validate_date("2020-04-01T12:00") diff --git a/setup.py b/setup.py index cd63b97..9d6afd3 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ from setuptools import find_packages, setup -install_requires = ["Django>=1.11,<3.3"] +install_requires = ["Django>=1.11,<=4"] testing_extras = [ "coverage>=3.7.0", - "django-debug-toolbar>=2.0,<2.3", + "django-debug-toolbar>=3.2,<4", "jinja2", ] @@ -24,7 +24,7 @@ long_description=open("README.md", "r", encoding="utf-8").read(), long_description_content_type="text/markdown", license="CC0", - version="5.0.5", + version="5.0.6", include_package_data=True, packages=find_packages(), python_requires=">=3.6", diff --git a/tox.ini b/tox.ini index cef34b7..194367e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,26 +1,27 @@ [tox] skipsdist=True -envlist=lint,py{36,38}-dj{22,32} +envlist=lint,py{36,39}-dj{22,32},py39-dj40 [testenv] install_command=pip install -e ".[testing]" -U {opts} {packages} commands= coverage erase - coverage run --source='flags' {envbindir}/django-admin.py test {posargs} + coverage run --source='flags' {envbindir}/django-admin test {posargs} coverage report -m setenv= DJANGO_SETTINGS_MODULE=flags.tests.settings basepython= py36: python3.6 - py38: python3.8 + py39: python3.9 deps= dj22: Django>=2.2,<2.3 dj32: Django>=3.2,<3.3 + dj40: Django>=4.0,<4.1 [testenv:lint] -basepython=python3.8 +basepython=python3.9 deps= black flake8