Skip to content

Commit

Permalink
Merge pull request #88 from cfpb/django40-python39
Browse files Browse the repository at this point in the history
Add Django 4.0 support and update to test against Python 3.9
  • Loading branch information
willbarton committed Jan 10, 2022
2 parents 8ed2529 + 36143f2 commit 00e6c20
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 25 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/test.yml
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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

Expand All @@ -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

Expand Down
11 changes: 9 additions & 2 deletions 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?
Expand Down Expand Up @@ -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))
Expand All @@ -157,7 +164,7 @@ TEMPLATES = [
],
}
},
]
]
```

## 3.0.2
Expand Down
3 changes: 2 additions & 1 deletion 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


Expand All @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions 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
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions 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",
]

Expand All @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions 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
Expand Down

0 comments on commit 00e6c20

Please sign in to comment.