Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize pre-commit to help devs follow style guidelines #1495

Merged
merged 5 commits into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pycqa/doc8
rev: 0.9.0
hooks:
- id: doc8
- repo: https://github.com/pycqa/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: rst-backticks
- id: rst-directive-colons
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.2
hooks:
- id: prettier
types_or: [javascript, css]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.0.0-beta.0
hooks:
- id: eslint
files: \.js?$
types: [file]
- repo: https://github.com/psf/black
rev: 21.7b0
hooks:
- id: black
language_version: python3
entry: black --target-version=py36
1 change: 0 additions & 1 deletion .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ lang_map = sr@latin:sr_Latn
file_filter = debug_toolbar/locale/<lang>/LC_MESSAGES/django.po
source_file = debug_toolbar/locale/en/LC_MESSAGES/django.po
source_lang = en

6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/ca/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Libre El Chaval <[email protected]>, 2013
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Vlada Macek <[email protected]>, 2013
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Jannis Leidel <[email protected]>, 2012-2013
msgid ""
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Django Debug Toolbar\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-14 10:25-0500\n"
"POT-Creation-Date: 2021-08-23 19:54-0500\n"
"PO-Revision-Date: 2012-03-31 20:10+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# jcatalan <[email protected]>, 2014
# Leonardo J. Caballero G. <[email protected]>, 2013-2014
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# nanook <[email protected]>, 2012
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Pingax <[email protected]>, 2013
# claudep <[email protected]>, 2013
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# shaib <[email protected]>, 2012
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/id/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Muhammad Panji <[email protected]>, 2012
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Ingo Berben <[email protected]>, 2012-2013
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/pl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Konrad Mosoń <[email protected]>, 2013
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/pt/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# joseduraes <[email protected]>, 2014
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/pt_BR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Fábio <[email protected]>, 2013-2014
# Percy Pérez-Pinedo, 2009
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/sv_SE/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Alex Nordlund <[email protected]>, 2012-2013
# Alex Nordlund <[email protected]>, 2012
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/uk/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# Sergey Lysach <[email protected]>, 2013
msgid ""
Expand Down
4 changes: 2 additions & 2 deletions debug_toolbar/locale/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
#
#
#
# Translators:
# mozillazg <[email protected]>, 2013-2014
msgid ""
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/management/commands/debugsqlshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import django
import sqlparse
from django.core.management.commands.shell import Command # noqa
from django.core.management.commands.shell import Command # noqa: F401
from django.db import connection

if connection.vendor == "postgresql" and django.VERSION >= (3, 0, 0):
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/panels/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def clear(self, *args, **kwargs):
def has_key(self, *args, **kwargs):
# Ignore flake8 rules for has_key since we need to support caches
# that may be using has_key.
return self.cache.has_key(*args, **kwargs) # noqa
return self.cache.has_key(*args, **kwargs) # noqa: W601

@send_signal
def incr(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/panels/history/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from debug_toolbar.panels.history.panel import HistoryPanel # noqa
from debug_toolbar.panels.history.panel import HistoryPanel # noqa: F401
2 changes: 1 addition & 1 deletion debug_toolbar/panels/sql/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from debug_toolbar.panels.sql.panel import SQLPanel # noqa
from debug_toolbar.panels.sql.panel import SQLPanel # noqa: F401
2 changes: 1 addition & 1 deletion debug_toolbar/panels/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from debug_toolbar.panels.templates.panel import TemplatesPanel # noqa
from debug_toolbar.panels.templates.panel import TemplatesPanel # noqa: F401
6 changes: 3 additions & 3 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ This version is compatible with Django 1.9 and requires Django 1.7 or later.
New features
~~~~~~~~~~~~

* New panel method :meth:`debug_toolbar.panels.Panel.generate_stats` allows panels
to only record stats when the toolbar is going to be inserted into the
response.
* New panel method :meth:`debug_toolbar.panels.Panel.generate_stats` allows
panels to only record stats when the toolbar is going to be inserted into
the response.

Bug fixes
~~~~~~~~~
Expand Down
5 changes: 4 additions & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ Panel options

**Without grouping**::

SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name"
SELECT
"auth_user"."id", "auth_user"."password", "auth_user"."last_login",
"auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name",
"auth_user"."last_name"
FROM "auth_user"
WHERE "auth_user"."username" = '''test_username'''
LIMIT 21
Expand Down
16 changes: 11 additions & 5 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ or by setting the ``DJANGO_SELENIUM_TESTS`` environment variable::
$ DJANGO_SELENIUM_TESTS=true make coverage
$ DJANGO_SELENIUM_TESTS=true tox

To test via `tox` against other databases, you'll need to create the user,
database and assign the proper permissions. For PostgreSQL in a `psql`
To test via ``tox`` against other databases, you'll need to create the user,
database and assign the proper permissions. For PostgreSQL in a ``psql``
shell (note this allows the debug_toolbar user the permission to create
databases)::

Expand All @@ -89,7 +89,7 @@ databases)::
psql> CREATE DATABASE debug_toolbar;
psql> GRANT ALL PRIVILEGES ON DATABASE debug_toolbar to debug_toolbar;

For MySQL/MariaDB in a `mysql` shell::
For MySQL/MariaDB in a ``mysql`` shell::

mysql> CREATE DATABASE debug_toolbar;
mysql> CREATE USER 'debug_toolbar'@'localhost' IDENTIFIED BY 'debug_toolbar';
Expand All @@ -101,8 +101,14 @@ Style
-----

The Django Debug Toolbar uses `black <https://github.com/psf/black>`__ to
format code and additionally uses flake8 and isort. You can reformat the code
using::
format code and additionally uses flake8 and isort. The toolbar uses
`pre-commit <https://pre-commit>`__ to automatically apply our style guidelines
when a commit is made. If necessary this can be bypassed using::

$ git commit --no-verify


To reformat the code manually use::

$ make style

Expand Down
20 changes: 13 additions & 7 deletions docs/panels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ Memcache

URL: https://github.com/ross/memcache-debug-panel

Path: ``memcache_toolbar.panels.memcache.MemcachePanel`` or ``memcache_toolbar.panels.pylibmc.PylibmcPanel``
Path: ``memcache_toolbar.panels.memcache.MemcachePanel`` or
``memcache_toolbar.panels.pylibmc.PylibmcPanel``

This panel tracks memcached usage. It currently supports both the pylibmc and
memcache libraries.
Expand All @@ -241,7 +242,8 @@ URL: https://github.com/robinedwards/django-debug-toolbar-neo4j-panel

Path: ``neo4j_panel.Neo4jPanel``

Trace neo4j rest API calls in your Django application, this also works for neo4django and neo4jrestclient, support for py2neo is on its way.
Trace neo4j rest API calls in your Django application, this also works for
neo4django and neo4jrestclient, support for py2neo is on its way.

Pympler
~~~~~~~
Expand All @@ -250,7 +252,8 @@ URL: https://pythonhosted.org/Pympler/django.html

Path: ``pympler.panels.MemoryPanel``

Shows process memory information (virtual size, resident set size) and model instances for the current request.
Shows process memory information (virtual size, resident set size) and model
instances for the current request.

Request History
~~~~~~~~~~~~~~~
Expand All @@ -259,7 +262,8 @@ URL: https://github.com/djsutho/django-debug-toolbar-request-history

Path: ``ddt_request_history.panels.request_history.RequestHistoryPanel``

Switch between requests to view their stats. Also adds support for viewing stats for AJAX requests.
Switch between requests to view their stats. Also adds support for viewing
stats for AJAX requests.

Requests
~~~~~~~~
Expand Down Expand Up @@ -289,8 +293,9 @@ URL: https://github.com/node13h/django-debug-toolbar-template-profiler

Path: ``template_profiler_panel.panels.template.TemplateProfilerPanel``

Shows template render call duration and distribution on the timeline. Lightweight.
Compatible with WSGI servers which reuse threads for multiple requests (Werkzeug).
Shows template render call duration and distribution on the timeline.
Lightweight. Compatible with WSGI servers which reuse threads for multiple
requests (Werkzeug).

Template Timings
~~~~~~~~~~~~~~~~
Expand All @@ -317,7 +322,8 @@ URL: https://github.com/giginet/django-debug-toolbar-vcs-info

Path: ``vcs_info_panel.panels.GitInfoPanel``

Displays VCS status (revision, branch, latest commit log and more) of your Django application.
Displays VCS status (revision, branch, latest commit log and more) of your
Django application.

uWSGI Stats
~~~~~~~~~~~
Expand Down
5 changes: 3 additions & 2 deletions docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ development.
The cache panel is very similar to the SQL panel, except it isn't always a bad
practice to make many cache queries in a view.

The template panel becomes slow if your views or context processors return large
contexts and your templates have complex inheritance or inclusion schemes.
The template panel becomes slow if your views or context processors return
large contexts and your templates have complex inheritance or inclusion
schemes.

Solutions
~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ sphinxcontrib-spelling

# Other tools

pre-commit
transifex-client
wheel
Loading