Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jazzband/django-waffle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0
Choose a base ref
...
head repository: jazzband/django-waffle
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 768 additions and 393 deletions.
  1. +9 −0 .github/dependabot.yml
  2. +84 −17 .github/workflows/python-package.yml
  3. +11 −0 .pre-commit-config.yaml
  4. +31 −0 .readthedocs.yaml
  5. +25 −1 CHANGES
  6. +16 −6 CONTRIBUTING.rst
  7. +0 −1 LICENSE
  8. +13 −4 README.rst
  9. +3 −4 RELEASING.rst
  10. +6 −6 docs/about/contributing.rst
  11. +7 −7 docs/about/roadmap.rst
  12. +4 −15 docs/about/why-waffle.rst
  13. +6 −5 docs/conf.py
  14. +2 −3 docs/index.rst
  15. +17 −1 docs/starting/configuring.rst
  16. +4 −21 docs/starting/installation.rst
  17. +2 −4 docs/testing/automated.rst
  18. +4 −4 docs/testing/user.rst
  19. +22 −12 docs/types/flag.rst
  20. +14 −4 docs/types/sample.rst
  21. +13 −4 docs/types/switch.rst
  22. +1 −1 docs/usage/decorators.rst
  23. +1 −1 docs/usage/json.rst
  24. +1 −1 docs/usage/mixins.rst
  25. +2 −2 docs/usage/templates.rst
  26. +1 −1 docs/usage/views.rst
  27. +153 −0 pyproject.toml
  28. +2 −2 requirements.txt
  29. +2 −2 requirements/test.txt
  30. +5 −2 run.sh
  31. +0 −3 setup.cfg
  32. +0 −36 setup.py
  33. +10 −10 test_app/urls.py
  34. +1 −1 test_settings.py
  35. +21 −7 tox.ini
  36. +0 −9 waffle/.flake8
  37. +20 −16 waffle/__init__.py
  38. +27 −18 waffle/admin.py
  39. +1 −1 waffle/apps.py
  40. +15 −6 waffle/decorators.py
  41. +1 −1 waffle/jinja.py
  42. +2 −2 waffle/locale/ru/LC_MESSAGES/django.po
  43. +8 −6 waffle/management/commands/waffle_delete.py
  44. +73 −61 waffle/management/commands/waffle_flag.py
  45. +8 −5 waffle/management/commands/waffle_sample.py
  46. +9 −7 waffle/management/commands/waffle_switch.py
  47. +14 −6 waffle/managers.py
  48. +2 −1 waffle/middleware.py
  49. +5 −3 waffle/mixins.py
  50. +38 −27 waffle/models.py
  51. 0 waffle/py.typed
  52. +4 −5 waffle/templatetags/waffle_tags.py
  53. +2 −1 waffle/tests/test_management.py
  54. +2 −2 waffle/tests/test_middleware.py
  55. +6 −0 waffle/tests/test_models.py
  56. +3 −3 waffle/tests/test_testutils.py
  57. +21 −18 waffle/testutils.py
  58. +7 −4 waffle/utils.py
  59. +7 −3 waffle/views.py
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
101 changes: 84 additions & 17 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -15,16 +15,17 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 3.7, 3.8, 3.9, '3.10' ]
python-version: [ 3.8, 3.9, '3.10', 3.11, 3.12, 3.13 ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
@@ -43,9 +44,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
@@ -57,19 +58,36 @@ jobs:
python -m pip install tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint
run: ruff check --output-format=github .

typecheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ matrix.python-version }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Type-check
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
tox -e typecheck
i18n:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
@@ -87,17 +105,66 @@ jobs:
run: |
tox -e i18n
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ matrix.python-version }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[docs]
- name: Build docs
run: |
sphinx-build -b html docs docs/_build
coverage:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install coverage
- name: Run coverage
run: |
source .venv/bin/activate
export DJANGO_SETTINGS_MODULE="test_settings"
export PYTHONPATH=.".:$PYTHONPATH"
python -m coverage run --source=waffle `which django-admin` test waffle
coverage report -m
coverage html
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5

release-production:
# Only upload if a tag is pushed (otherwise just build & check)
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

runs-on: ubuntu-latest

needs: [test, lint, i18n]
needs: [test, lint, i18n, docs, coverage]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v5.0.0'
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# Here we follow https://docs.readthedocs.io/en/stable/config-file/v2.html#packages
python:
install:
- method: pip
path: .
extra_requirements:
- docs
26 changes: 25 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -2,6 +2,30 @@
Waffle Changelog
================

v4.2.0
======
- Joined Jazzband (https://jazzband.co/)
- Linting improvements and cleanups
- Added support for Django 5.0 and 5.1
- Added support for Python 3.13

v4.1.0
======
- Updated `is_active_for_user` method to account for `everyone` option
- Added `--testing` option to waffle_flag management command

v4.0.0
======
- Added support for Django 4.2 and Python 3.11
- Dropped support for Python 3.7
- Added type hints

v3.0.0
======
- Added support for pluggable Sample and Switch models
- Removed support EOL Python versions
- Removed support for EOL Django versions

v2.7.0
======
- Exposed JSON endpoint for Waffle flag/switch/sample state
@@ -95,7 +119,7 @@ v0.16.0
- Using strings as cache keys instead of bytes
- Passing effects of test decorator to child classes
-- NOTE: This introduced a backwards-incompatible change for the testutils override decorators.
See https://github.com/django-waffle/django-waffle/pull/331 for details.
See https://github.com/jazzband/django-waffle/pull/331 for details.

v0.15.1
=======
22 changes: 16 additions & 6 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -5,6 +5,14 @@
Contributing to Waffle
======================

.. image:: https://jazzband.co/static/img/jazzband.svg
:target: https://jazzband.co/
:alt: Jazzband

This is a `Jazzband <https://jazzband.co>`_ project. By contributing you agree to abide by the
`Contributor Code of Conduct <https://jazzband.co/about/conduct>`_ and follow the
`guidelines <https://jazzband.co/about/guidelines>`_.

Waffle is pretty simple to hack, and has a decent test suite! Here's how
to patch Waffle, add tests, run them, and contribute changes.

@@ -52,24 +60,26 @@ and squashed into a minimal set of commits. Each commit should include
the necessary code, test, and documentation changes for a single "piece"
of functionality.

To be mergable, patches must:
To be mergeable, patches must:

- be rebased onto the latest master,
- be automatically mergeable,
- not break existing tests,
- not change existing tests without a *very* good reason,
- add tests for new code (bug fixes should include regression tests, new
features should have relevant tests),
- not introduce any new flake8_ errors (run ``./run.sh lint``),
- not introduce any new ruff_ errors (run ``./run.sh lint``),
- not introduce any new mypy_ errors (run ``./run.sh typecheck``),
- include updated source translations (run ``./run.sh makemessages`` and ``./run.sh compilemessages``),
- document any new features, and
- have a `good commit message`_.

Regressions tests should fail without the rest of the patch and pass
with it.
with it.


.. _open a new issue: https://github.com/django-waffle/django-waffle/issues/new
.. _Fork: https://github.com/django-waffle/django-waffle/fork
.. _flake8: https://pypi.python.org/pypi/flake8
.. _open a new issue: https://github.com/jazzband/django-waffle/issues/new
.. _Fork: https://github.com/jazzband/django-waffle/fork
.. _ruff: https://pypi.python.org/pypi/ruff
.. _mypy: https://www.mypy-lang.org/
.. _good commit message: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -25,4 +25,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

17 changes: 13 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -6,14 +6,23 @@ Django Waffle is (yet another) feature flipper for Django. You can
define the conditions for which a flag should be active, and use it in
a number of ways.

.. image:: https://github.com/django-waffle/django-waffle/workflows/Python%20package/badge.svg?branch=master
:target: https://github.com/django-waffle/django-waffle/actions
.. image:: https://jazzband.co/static/img/badge.svg
:target: https://jazzband.co/
:alt: Jazzband
.. image:: https://github.com/jazzband/django-waffle/workflows/Python%20package/badge.svg?branch=master
:target: https://github.com/jazzband/django-waffle/actions
:alt: Build Status
.. image:: https://badge.fury.io/py/django-waffle.svg
:target: https://badge.fury.io/py/django-waffle
:alt: PyPI status badge
.. image:: https://img.shields.io/readthedocs/waffle
:target: https://app.readthedocs.org/projects/waffle
:alt: Read the Docs
.. image:: https://codecov.io/gh/jazzband/django-waffle/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jazzband/django-waffle
:alt: Codecov

:Code: https://github.com/django-waffle/django-waffle
:Code: https://github.com/jazzband/django-waffle
:License: BSD; see LICENSE file
:Issues: https://github.com/django-waffle/django-waffle/issues
:Issues: https://github.com/jazzband/django-waffle/issues
:Documentation: https://waffle.readthedocs.io/
7 changes: 3 additions & 4 deletions RELEASING.rst
Original file line number Diff line number Diff line change
@@ -5,14 +5,13 @@ These are the steps necessary to release a new version of Django Waffle.

1. Update the version number in the following files:

a. `setup.py`
b. `docs/conf.py`
c. `waffle/__init__.py`
a. `docs/conf.py`
b. `waffle/__init__.py`

2. Update the changelog in `CHANGES`.

3. Merge these changes to the `master` branch.

4. Create a new release on GitHub. This will also create a Git tag, and trigger a push to PyPI.
4. Create a new release on GitHub. This will also create a git tag, and trigger a push to PyPI.

5. Ensure the documentation build passes: https://readthedocs.org/projects/waffle/
12 changes: 6 additions & 6 deletions docs/about/contributing.rst
Original file line number Diff line number Diff line change
@@ -52,23 +52,23 @@ and squashed into a minimal set of commits. Each commit should include
the necessary code, test, and documentation changes for a single "piece"
of functionality.

To be mergable, patches must:
To be mergeable, patches must:

- be rebased onto the latest master,
- be automatically mergeable,
- not break existing tests,
- not change existing tests without a *very* good reason,
- add tests for new code (bug fixes should include regression tests, new
features should have relevant tests),
- not introduce any new flake8_ errors (run ``./run.sh lint``),
- not introduce any new ruff_ errors (run ``./run.sh lint``),
- document any new features, and
- have a `good commit message`_.

Regressions tests should fail without the rest of the patch and pass
with it.
with it.


.. _open a new issue: https://github.com/django-waffle/django-waffle/issues/new
.. _Fork: https://github.com/django-waffle/django-waffle/fork
.. _flake8: https://pypi.python.org/pypi/flake8
.. _open a new issue: https://github.com/jazzband/django-waffle/issues/new
.. _Fork: https://github.com/jazzband/django-waffle/fork
.. _ruff: https://pypi.python.org/pypi/ruff
.. _good commit message: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
14 changes: 7 additions & 7 deletions docs/about/roadmap.rst
Original file line number Diff line number Diff line change
@@ -119,11 +119,11 @@ scratch today with slightly different goals, like extensibility. Beyond
kind of overhaul.


.. _milestones: https://github.com/django-waffle/django-waffle/milestones
.. _0.10.2: https://github.com/django-waffle/django-waffle/milestones/0.10.2
.. _0.11: https://github.com/django-waffle/django-waffle/milestones/0.11
.. _0.11.x: https://github.com/django-waffle/django-waffle/milestones/0.11.x
.. _0.12: https://github.com/django-waffle/django-waffle/milestones/0.12
.. _0.13: https://github.com/django-waffle/django-waffle/milestones/0.13
.. _milestones: https://github.com/jazzband/django-waffle/milestones
.. _0.10.2: https://github.com/jazzband/django-waffle/milestones/0.10.2
.. _0.11: https://github.com/jazzband/django-waffle/milestones/0.11
.. _0.11.x: https://github.com/jazzband/django-waffle/milestones/0.11.x
.. _0.12: https://github.com/jazzband/django-waffle/milestones/0.12
.. _0.13: https://github.com/jazzband/django-waffle/milestones/0.13
.. _Gargoyle: https://github.com/disqus/gargoyle
.. _django-jinja: https://niwinz.github.io/django-jinja/latest/
.. _django-jinja: https://niwinz.github.io/django-jinja/latest/
Loading