Skip to content

Commit

Permalink
Merge branch 'master' into feature/adding-template-filter-for-switch-…
Browse files Browse the repository at this point in the history
…flag-sample-usable-for-if-statements
  • Loading branch information
MatthewEthanTam authored Nov 17, 2024
2 parents fded0ae + b697b31 commit 2d137d5
Show file tree
Hide file tree
Showing 30 changed files with 231 additions and 132 deletions.
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

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"
37 changes: 17 additions & 20 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, '3.10', '3.11' ]
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') }}
Expand All @@ -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') }}
Expand All @@ -57,19 +58,15 @@ jobs:
python -m pip install tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint
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
run: ruff check --output-format=github .

typecheck:
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') }}
Expand All @@ -88,9 +85,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') }}
Expand All @@ -117,8 +114,8 @@ jobs:
needs: [test, lint, i18n]

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 }}
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
repos:
- repo: https://github.com/pycqa/flake8
rev: '7.1.1'
hooks:
- id: flake8
exclude: docs/conf.py|test_settings.py
- 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.7.3
hooks:
- id: ruff
27 changes: 27 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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
# python:
# install:
# - requirements: docs/requirements.txt
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
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
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ To be mergeable, patches must:
- 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
Expand All @@ -80,6 +80,6 @@ with it.

.. _open a new issue: https://github.com/jazzband/django-waffle/issues/new
.. _Fork: https://github.com/jazzband/django-waffle/fork
.. _flake8: https://pypi.python.org/pypi/flake8
.. _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
4 changes: 2 additions & 2 deletions docs/about/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To be mergeable, patches must:
- 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`_.

Expand All @@ -70,5 +70,5 @@ with it.

.. _open a new issue: https://github.com/jazzband/django-waffle/issues/new
.. _Fork: https://github.com/jazzband/django-waffle/fork
.. _flake8: https://pypi.python.org/pypi/flake8
.. _ruff: https://pypi.python.org/pypi/ruff
.. _good commit message: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
15 changes: 2 additions & 13 deletions docs/about/why-waffle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,20 @@ Waffle :ref:`aims to <about-goals>`
Waffle has an `active community`_ and gets `fairly steady updates`_.


vs Gargoyle
===========

The other major, active feature flag tool for Django is Disqus's
Gargoyle_. Both support similar features, though Gargoyle offers more
options for building custom segments in exchange for some more
complexity and requirements.


Waffle in Production
====================

Despite its pre-1.0 version number, Waffle has been used in production
for years at places like Mozilla, Yipit and TodaysMeet.
Waffle has been used in production for years at places like Mozilla, Yipit and TodaysMeet.

- Mozilla (Support, MDN, Addons, etc)
- TodaysMeet
- Yipit

(If you're using Waffle in production and don't mind being included
here, let me know or add yourself in a pull request!)
here, let us know or add yourself in a pull request!)


.. _Feature flags: http://code.flickr.net/2009/12/02/flipping-out/
.. _several options: https://www.djangopackages.com/grids/g/feature-flip/
.. _active community: https://github.com/jazzband/django-waffle/graphs/contributors
.. _fairly steady updates: https://github.com/jazzband/django-waffle/pulse/monthly
.. _Gargoyle: https://github.com/disqus/gargoyle
7 changes: 4 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import sys
import os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -46,9 +47,9 @@
# built documents.
#
# The short X.Y version.
version = '4.1'
version = '4.2'
# The full version, including alpha/beta/rc tags.
release = '4.1.0'
release = '4.2.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/starting/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ behavior.
The value describes the level of wanted warning, possible values are all levels know by pythons default logging,
e.g. ``logging.WARNING``.
Defaults to ``None``.


``WAFFLE_ENABLE_ADMIN_PAGES``
Enables the default admin pages for Waffle models. This is True by default,
Expand Down
23 changes: 3 additions & 20 deletions docs/starting/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ met, installing Waffle is a simple process.
Getting Waffle
==============

Waffle is `hosted on PyPI`_ and can be installed with ``pip`` or
``easy_install``:
Waffle is `hosted on PyPI`_ and can be installed with ``pip``

.. code-block:: shell
$ pip install django-waffle
$ easy_install django-waffle
Waffle is also available `on GitHub`_. In general, ``master`` should be
stable, but use caution depending on unreleased versions.
Expand Down Expand Up @@ -80,33 +78,18 @@ With django-jinja_, add the extension to the ``extensions`` list::
# ...
]

With jingo_, add it to the ``JINJA_CONFIG['extensions']`` list::

JINJA_CONFIG = {
'extensions': [
# ...
'waffle.jinja.WaffleExtension',
],
# ...
}


.. _installation-settings-migrations:

Database Schema
===============

Waffle includes `Django migrations`_ for creating the correct database
schema. If using Django >= 1.7, simply run the ``migrate`` management
command after adding Waffle to ``INSTALLED_APPS``:
schema. Simply run the ``migrate`` management command after adding Waffle to
``INSTALLED_APPS``:

.. code-block:: shell
$ django-admin.py migrate
If you're using a version of Django without migrations, you can run
``syncdb`` to create the Waffle tables.

.. _Django migrations: https://docs.djangoproject.com/en/dev/topics/migrations/
.. _django-jinja: https://pypi.python.org/pypi/django-jinja/
.. _jingo: http://jingo.readthedocs.org/
6 changes: 2 additions & 4 deletions docs/testing/automated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ Tests that run in a separate process, such as Selenium tests, may not
have access to the test database or the ability to mock Waffle values.

For tests that make HTTP requests to the system-under-test (e.g. with
Selenium_ or PhantomJS_) the ``WAFFLE_OVERRIDE`` :ref:`setting
<starting-configuring>` makes it possible to control the value of any
*Flag* via the querystring.
Selenium_) the ``WAFFLE_OVERRIDE`` :ref:`setting <starting-configuring>`
makes it possible to control the value of any *Flag* via the querystring.

.. highlight:: http

Expand All @@ -72,4 +71,3 @@ or that it is "off"::
.. _mock: http://pypi.python.org/pypi/mock/
.. _fudge: http://farmdev.com/projects/fudge/
.. _Selenium: http://www.seleniumhq.org/
.. _PhantomJS: http://phantomjs.org/
2 changes: 1 addition & 1 deletion docs/testing/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ Wow, good work!
You can use similar methods to derive the impact on other factors.


.. _session variables: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#custom-vars
.. _session variables: https://support.google.com/analytics/answer/9191807?hl=en
.. _#80: https://github.com/jazzband/django-waffle/issues/80
.. _StatsD: https://github.com/etsy/statsd
2 changes: 1 addition & 1 deletion docs/usage/decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Flags
@waffle_flag('flag_name')
def myview(request):
pass

@waffle_flag('flag_name', 'url_name_to_redirect_to')
def myotherview(request):
pass
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ features on the front-end. It includes support for both Django's
built-in templates and for Jinja2_.

.. warning::

Before using samples in templates, see the warning in the
:ref:`Sample chapter <types-sample>`.

Expand Down Expand Up @@ -92,7 +92,7 @@ Switches
--------

::

{% if waffle.switch('switch_name') %}
switch_name is active!
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ Samples
Returns ``True`` if the sample is active, else ``False``.

.. warning::

See the warning in the :ref:`Sample chapter <types-sample>`.
Loading

0 comments on commit 2d137d5

Please sign in to comment.