diff --git a/.darglint b/.darglint new file mode 100644 index 0000000..2b03755 --- /dev/null +++ b/.darglint @@ -0,0 +1,2 @@ +[darglint] +strictness = short diff --git a/.flake8 b/.flake8 index 891336c..37cca8f 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -select = ANN,B,B9,BLK,C,D,DAR,E,F,S,W +select = ANN,B,B9,BLK,C,E,F,S,W ignore = E203,E501,W503,C901,S308 max-line-length = 80 max-complexity = 10 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25c5720..59a30bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,16 +15,16 @@ repos: rev: 19.10b0 hooks: - id: black - # - repo: https://gitlab.com/pycqa/flake8 - # rev: 3.7.9 - # hooks: - # - id: flake8 - # additional_dependencies: - # - flake8-bandit==2.1.2 - # - flake8-bugbear==20.1.4 - # - flake8-docstrings==1.5.0 - # - pep8-naming==0.10.0 - # - darglint==1.2.3 + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-bandit==2.1.2 + - flake8-bugbear==20.1.4 + - flake8-docstrings==1.5.0 + - pep8-naming==0.10.0 + - darglint==1.3.0 - repo: https://github.com/asottile/reorder_python_imports rev: v2.3.0 hooks: diff --git a/noxfile.py b/noxfile.py index dfed133..a569e31 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,5 @@ """Nox sessions.""" import contextlib -import shutil import tempfile from pathlib import Path from typing import cast @@ -140,8 +139,18 @@ def tests(session: Session) -> None: """Run the test suite.""" install_package(session) install(session, "coverage[toml]", "pytest") - session.run("coverage", "run", "-m", "pytest", *session.posargs) - session.run("coverage", "report") + session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs) + session.notify("coverage") + + +@nox.session +def coverage(session: Session) -> None: + """Produce the coverage report.""" + args = session.posargs or ["report"] + install(session, "coverage[toml]") + if not session.posargs and any(Path().glob(".coverage.*")): + session.run("coverage", "combine") + session.run("coverage", *args) @nox.session(python=python_versions) diff --git a/sample/mysite/manage.py b/sample/mysite/manage.py deleted file mode 100755 index be146f8..0000000 --- a/sample/mysite/manage.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == "__main__": - main() diff --git a/sample/mysite/mysite/__init__.py b/sample/mysite/mysite/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/sample/mysite/mysite/settings.py b/sample/mysite/mysite/settings.py deleted file mode 100644 index 94c9625..0000000 --- a/sample/mysite/mysite/settings.py +++ /dev/null @@ -1,115 +0,0 @@ -""" -Django settings for mysite project. - -Generated by 'django-admin startproject' using Django 2.2.11. - -For more information on this file, see -https://docs.djangoproject.com/en/2.2/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.2/ref/settings/ -""" -import os - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "2ub524wek9yr4-#hf7))&l_@26s&eusy)lw&n=dv7wat=^d8ke" - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition - -INSTALLED_APPS = [ - "django_sorting_bootstrap", - "polls.apps.PollsConfig", - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", -] - -MIDDLEWARE = [ - "django.middleware.security.SecurityMiddleware", - "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", - "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.clickjacking.XFrameOptionsMiddleware", -] - -ROOT_URLCONF = "mysite.urls" - -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [os.path.join(BASE_DIR, "templates")], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.debug", - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ], - }, - }, -] - -WSGI_APPLICATION = "mysite.wsgi.application" - - -# Database -# https://docs.djangoproject.com/en/2.2/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": os.path.join(BASE_DIR, "db.sqlite3"), - } -} - - -# Password validation -# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",}, - {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",}, - {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",}, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.2/topics/i18n/ - -LANGUAGE_CODE = "en-us" - -TIME_ZONE = "UTC" - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.2/howto/static-files/ - -STATIC_URL = "/static/" diff --git a/sample/mysite/mysite/urls.py b/sample/mysite/mysite/urls.py deleted file mode 100644 index 37e7e22..0000000 --- a/sample/mysite/mysite/urls.py +++ /dev/null @@ -1,23 +0,0 @@ -"""mysite URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import include -from django.urls import path - -urlpatterns = [ - path("polls/", include("polls.urls")), - path("admin/", admin.site.urls), -] diff --git a/sample/mysite/mysite/wsgi.py b/sample/mysite/mysite/wsgi.py deleted file mode 100644 index 8fde7d1..0000000 --- a/sample/mysite/mysite/wsgi.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -WSGI config for mysite project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ -""" -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") - -application = get_wsgi_application() diff --git a/sample/mysite/polls/__init__.py b/sample/mysite/polls/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/sample/mysite/polls/admin.py b/sample/mysite/polls/admin.py deleted file mode 100644 index 85b58fb..0000000 --- a/sample/mysite/polls/admin.py +++ /dev/null @@ -1,23 +0,0 @@ -from django.contrib import admin - -from .models import Choice -from .models import Question - - -class ChoiceInline(admin.TabularInline): - model = Choice - extra = 3 - - -class QuestionAdmin(admin.ModelAdmin): - fieldsets = [ - (None, {"fields": ["question_text"]}), - ("Date information", {"fields": ["pub_date"]}), - ] - list_display = ("question_text", "pub_date", "was_published_recently") - list_filter = ["pub_date"] - search_fields = ["question_text"] - - -admin.site.register(Choice) -admin.site.register(Question, QuestionAdmin) diff --git a/sample/mysite/polls/apps.py b/sample/mysite/polls/apps.py deleted file mode 100644 index 292f00d..0000000 --- a/sample/mysite/polls/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class PollsConfig(AppConfig): - name = "polls" diff --git a/sample/mysite/polls/migrations/0001_initial.py b/sample/mysite/polls/migrations/0001_initial.py deleted file mode 100644 index c7fb2b9..0000000 --- a/sample/mysite/polls/migrations/0001_initial.py +++ /dev/null @@ -1,52 +0,0 @@ -# Generated by Django 2.2.11 on 2020-03-16 13:43 -import django.db.models.deletion -from django.db import migrations -from django.db import models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [] - - operations = [ - migrations.CreateModel( - name="Question", - fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("question_text", models.CharField(max_length=200)), - ("pub_date", models.DateTimeField(verbose_name="date published")), - ], - ), - migrations.CreateModel( - name="Choice", - fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("choice_text", models.CharField(max_length=200)), - ("votes", models.IntegerField(default=0)), - ( - "question", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, to="polls.Question" - ), - ), - ], - ), - ] diff --git a/sample/mysite/polls/migrations/__init__.py b/sample/mysite/polls/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/sample/mysite/polls/models.py b/sample/mysite/polls/models.py deleted file mode 100644 index a0639e4..0000000 --- a/sample/mysite/polls/models.py +++ /dev/null @@ -1,29 +0,0 @@ -import datetime - -from django.db import models -from django.utils import timezone - - -class Question(models.Model): - question_text = models.CharField(max_length=200) - pub_date = models.DateTimeField("date published") - - def __str__(self): - return self.question_text - - def was_published_recently(self): - now = timezone.now() - return now - datetime.timedelta(days=1) <= self.pub_date <= now - - was_published_recently.admin_order_field = "pub_date" - was_published_recently.boolean = True - was_published_recently.short_description = "Published recently?" - - -class Choice(models.Model): - question = models.ForeignKey(Question, on_delete=models.CASCADE) - choice_text = models.CharField(max_length=200) - votes = models.IntegerField(default=0) - - def __str__(self): - return self.choice_text diff --git a/sample/mysite/polls/static/polls/images/background.gif b/sample/mysite/polls/static/polls/images/background.gif deleted file mode 100644 index 6d69c70..0000000 Binary files a/sample/mysite/polls/static/polls/images/background.gif and /dev/null differ diff --git a/sample/mysite/polls/static/polls/style.css b/sample/mysite/polls/static/polls/style.css deleted file mode 100644 index 9237035..0000000 --- a/sample/mysite/polls/static/polls/style.css +++ /dev/null @@ -1,7 +0,0 @@ -li a { - color: green; -} - -body { - background: white url("images/background.gif") no-repeat; -} diff --git a/sample/mysite/polls/templates/admin/base_site.html b/sample/mysite/polls/templates/admin/base_site.html deleted file mode 100644 index 626e5b7..0000000 --- a/sample/mysite/polls/templates/admin/base_site.html +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "admin/base.html" %} {% block title %}{{ title }} | {{ -site_title|default:_('Django site admin') }}{% endblock %} {% block branding %} -
{{ error_message }}
-{% endif %} - - diff --git a/sample/mysite/polls/templates/polls/index.html b/sample/mysite/polls/templates/polls/index.html deleted file mode 100644 index 2b75aa8..0000000 --- a/sample/mysite/polls/templates/polls/index.html +++ /dev/null @@ -1,17 +0,0 @@ -{% load static %} - - - -{% if latest_question_list %} -No polls are available.
-{% endif %} diff --git a/sample/mysite/polls/templates/polls/results.html b/sample/mysite/polls/templates/polls/results.html deleted file mode 100644 index dfe4f4f..0000000 --- a/sample/mysite/polls/templates/polls/results.html +++ /dev/null @@ -1,12 +0,0 @@ -