From 2640f000f44c6ee5343cc9cefcea33e2333cf164 Mon Sep 17 00:00:00 2001 From: Aleksei Pirogov Date: Thu, 11 Feb 2021 13:55:09 +0300 Subject: [PATCH] fix some linter warnings --- djaif/book/models.py | 4 ++-- djaif/book/tests.py | 3 --- djaif/book/views.py | 9 +++++---- djaif/urls.py | 15 --------------- setup.cfg | 10 +++++++--- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/djaif/book/models.py b/djaif/book/models.py index a1d6fa8..ece07cb 100644 --- a/djaif/book/models.py +++ b/djaif/book/models.py @@ -76,13 +76,13 @@ def save_to(self, save_id): state.items.set(self.items.all()) else: state = ProgressSave.objects.get(id=save_id) - state.book_page=self.book_page + state.book_page = self.book_page state.save() state.items.set(self.items.all()) def load_from(self, save_id): state = ProgressSave.objects.get(id=save_id) - self.book_page=state.book_page + self.book_page = state.book_page # noqa: WPS601 self.save() self.items.set(state.items.all()) diff --git a/djaif/book/tests.py b/djaif/book/tests.py index 7ce503c..e69de29 100644 --- a/djaif/book/tests.py +++ b/djaif/book/tests.py @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/djaif/book/views.py b/djaif/book/views.py index 8cd6016..0d69cbe 100644 --- a/djaif/book/views.py +++ b/djaif/book/views.py @@ -1,10 +1,9 @@ from functools import wraps -from graphviz import Digraph - +from django.http import FileResponse from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse -from django.http import FileResponse +from graphviz import Digraph from djaif.book import models @@ -36,9 +35,11 @@ def view_books(request): context={'books': models.Book.objects.all()}, ) + def view_book(request, book_id): book = get_object_or_404(models.Book, id=book_id) - assert book.first_page + if not book.first_page: + raise ValueError("Book {0.id} hasn't a first page!") try: progress = models.BookProgress.objects.get( book=book, user=request.user, diff --git a/djaif/urls.py b/djaif/urls.py index 54409c0..ee07ac7 100644 --- a/djaif/urls.py +++ b/djaif/urls.py @@ -1,18 +1,3 @@ -"""djaif URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.0/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.conf import settings from django.conf.urls.static import static from django.contrib import admin diff --git a/setup.cfg b/setup.cfg index 19d9f4b..5f09f09 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,14 +24,18 @@ exclude = .eggs *.egg **/migrations/** + manage.py ignore = # documentation isn't so important for now - D100, D101, D102, D103, D105, D106, + D100, D101, D102, D103, D104, D105, D106, # yes, we have bad names here and there WPS110, WPS111, # annoying stuff - WPS326, WPS306, WPS317, + WPS326, WPS306, WPS317, WPS202, WPS226, WPS411, WPS323, + # I like multiline conditions! + WPS337, W503, W504, per-file-ignores = - settings.py: WPS407, E501, C812, WPS221, WPS226 + settings.py: WPS407, E501, C812, WPS221, WPS226, S105 + models.py: WPS226