Skip to content

Commit

Permalink
Add pre-commit config with sensible hooks; apply those hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejalim committed Jan 24, 2024
1 parent 111c78f commit ef195a1
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

# Global excludes, override per repo below if different excludes required.
# exclude: >
# (?x)^(
# DIRNAME_OR_FILENAME_HERE
# | DIRNAME_OR_FILENAME_HERE
# | DIRNAME_OR_FILENAME_HERE
# )
repos:
# Note: hooks that add content must run before ones which check formatting, lint, etc
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Unreleased
- Drop support for EOL Python <3.8 and Django <2.2 versions
- Switch to ruff instead of pep8 and flake8
- Move from CircleCI to Github Actions for CI
- Add support for using pre-commit with the project

3.7
===
Expand Down
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Community Participation Guidelines

This repository is governed by Mozilla's code of conduct and etiquette guidelines.
This repository is governed by Mozilla's code of conduct and etiquette guidelines.
For more details, please read the
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).

## How to Report
For more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.
Expand Down
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.

2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Django-CSP adds Content-Security-Policy_ headers to Django.
The code lives on GitHub_, where you can report Issues_. The full
documentation is available on ReadTheDocs_.



.. _Content-Security-Policy: http://www.w3.org/TR/CSP/
.. _GitHub: https://github.com/mozilla/django-csp
.. _Issues: https://github.com/mozilla/django-csp/issues
Expand Down
3 changes: 3 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Style
Patches should follow PEP8_ and should not introduce any new violations
as detected by the ruff_ tool.

To help stay on top of this, install pre-commit_, and then run ``pre-commit install-hooks``. Now you'll be set up
to auto-format your code according to our style and check for errors for every commit.

Tests
=====
Expand All @@ -37,3 +39,4 @@ Then just `pytest`_ to run the tests::
.. _ruff: https://pypi.org/project/ruff/
.. _virtualenv: http://www.virtualenv.org/
.. _pytest: https://pytest.org/latest/usage.html
.. _pre-commit: https://pre-commit.com/#install
2 changes: 1 addition & 1 deletion docs/trusted_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ dangerous sink that requires Trusted Types.
``Step 3: Enforce Trusted Types``
=================================
Once you have addressed all of the Trusted Types violations present in your
application, you can begin enforcing Trusted Types to prevent DOM XSS.
application, you can begin enforcing Trusted Types to prevent DOM XSS.

Configure django-csp so that ``CSP_REPORT_ONLY`` is set to *False*.

Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ docstring-code-format = false
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"
docstring-code-line-length = "dynamic"

0 comments on commit ef195a1

Please sign in to comment.