Run lints and other checks. (#149)

This commit is contained in:
Jannis Leidel 2019-11-25 11:11:57 +01:00 committed by GitHub
parent 130fe397a4
commit ed857f7481
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 46 additions and 10 deletions

View file

@ -1,3 +1,3 @@
[run] [run]
omit = *_settings.py, defender/*migrations/*, defender/exampleapp/*, *test.py, omit = *_settings.py, defender/*migrations/*, exampleapp/*, *test.py,
*__init__.py, *tests.py, *urls.py *__init__.py, *tests.py, *urls.py

6
.eggs/README.txt Normal file
View file

@ -0,0 +1,6 @@
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
This directory caches those eggs to prevent repeated downloads.
However, it is safe to delete this directory.

5
.gitignore vendored
View file

@ -22,6 +22,7 @@ var/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST MANIFEST
.eggs
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template
@ -55,5 +56,5 @@ docs/_build/
target/ target/
# exampleapp # exampleapp
defender/exampleapp/static/ exampleapp/static/
defender/exampleapp/media/ exampleapp/media/

View file

@ -1,6 +1,12 @@
include CONTRIBUTING.rst include .coveragerc
include CHANGES.rst include CHANGES.rst
include README.rst include CONTRIBUTING.rst
include LICENSE include LICENSE
include README.rst
include requirements.txt
include tox.ini
recursive-include docs *
recursive-include exampleapp *
recursive-include defender/templates *.html recursive-include defender/templates *.html
recursive-exclude * *.py[co] recursive-exclude * *.py[co]
prune .eggs

View file

@ -14,6 +14,10 @@ django-defender
:target: https://codecov.io/gh/jazzband/django-defender :target: https://codecov.io/gh/jazzband/django-defender
:alt: Coverage :alt: Coverage
.. image:: https://readthedocs.org/projects/python-dockerflow/badge/?version=latest
:alt: Documentation Status
:target: https://django-defender.readthedocs.io/en/latest/?badge=latest
A simple Django reusable app that blocks people from brute forcing login A simple Django reusable app that blocks people from brute forcing login
attempts. The goal is to make this as fast as possible, so that we do not attempts. The goal is to make this as fast as possible, so that we do not

View file

@ -8,7 +8,7 @@ This is just a simple example app, used for testing and showing how things work
``` ```
mkdir -p exampleapp/static exampleapp/media/static mkdir -p exampleapp/static exampleapp/media/static
PYTHONPATH=$PYTHONPATH:$PWD django-admin.py collectstatic --noinput --settings=defender.exampleapp.settings PYTHONPATH=$PYTHONPATH:$PWD django-admin.py collectstatic --noinput --settings=exampleapp.settings
PYTHONPATH=$PYTHONPATH:$PWD django-admin.py runserver --settings=defender.exampleapp.settings PYTHONPATH=$PYTHONPATH:$PWD django-admin.py runserver --settings=exampleapp.settings
``` ```

View file

@ -30,7 +30,7 @@ MIDDLEWARE = (
"defender.middleware.FailedLoginMiddleware", "defender.middleware.FailedLoginMiddleware",
) )
ROOT_URLCONF = "defender.exampleapp.urls" ROOT_URLCONF = "exampleapp.urls"
INSTALLED_APPS = [ INSTALLED_APPS = [
"django.contrib.auth", "django.contrib.auth",
@ -61,7 +61,7 @@ DEFENDER_REDIS_URL = "redis://localhost:6379/1"
DEFENDER_MOCK_REDIS = False DEFENDER_MOCK_REDIS = False
# Let's use custom function and strip username string from request. # Let's use custom function and strip username string from request.
DEFENDER_GET_USERNAME_FROM_REQUEST_PATH = ( DEFENDER_GET_USERNAME_FROM_REQUEST_PATH = (
"defender.exampleapp.utils.strip_username_from_request" "exampleapp.utils.strip_username_from_request"
) )
# Celery settings: # Celery settings:
@ -70,7 +70,7 @@ BROKER_BACKEND = "memory"
BROKER_URL = "memory://" BROKER_URL = "memory://"
# set the default Django settings module for the 'celery' program. # set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "defender.exampleapp.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "exampleapp.settings")
app = Celery("defender") app = Celery("defender")

19
tox.ini
View file

@ -6,6 +6,7 @@ envlist =
py35-django(21,22) py35-django(21,22)
py{36,37,py3}-django{21,22,master} py{36,37,py3}-django{21,22,master}
py38-django22 py38-django22
py38-{lint,docs}
[travis] [travis]
python = python =
@ -28,3 +29,21 @@ usedevelop = True
commands = commands =
{envbindir}/coverage run --source=defender {envbindir}/django-admin.py test defender --settings=defender.travis_settings {envbindir}/coverage run --source=defender {envbindir}/django-admin.py test defender --settings=defender.travis_settings
{envbindir}/coverage report -m {envbindir}/coverage report -m
[testenv:py38-docs]
basepython = python3.8
deps =
-rrequirements.txt
Sphinx
sphinx_rtd_theme
commands = sphinx-build -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
[testenv:py38-lint]
basepython = python3.8
deps =
twine
check-manifest
commands =
check-manifest -v
python setup.py sdist
twine check dist/*