From: Frédéric Péters Date: Sat, 16 Jul 2022 21:27:01 +0000 (+0200) Subject: trivial: apply new pre-commit hooks X-Git-Tag: v2023~31 X-Git-Url: https://git.0d.be/?p=chloro.git;a=commitdiff_plain;h=1a3a57e0bb2b9af5ea1b84878a348e80cf8f8c81 trivial: apply new pre-commit hooks --- diff --git a/chloro/monkeypatch.py b/chloro/monkeypatch.py index c0c7142..127dc86 100644 --- a/chloro/monkeypatch.py +++ b/chloro/monkeypatch.py @@ -14,18 +14,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.urls import reverse +import ckeditor.views +import ckeditor.widgets +from ckeditor.image import pillow_backend from django.forms.utils import flatatt from django.template.loader import render_to_string +from django.urls import reverse from django.utils.encoding import force_text from django.utils.html import conditional_escape from django.utils.safestring import mark_safe from django.utils.translation import get_language -import ckeditor.views -import ckeditor.widgets -from ckeditor.image import pillow_backend - def ckeditor_render(self, name, value, attrs=None, renderer=None): if value is None: diff --git a/chloro/phyll/fields.py b/chloro/phyll/fields.py index 2ce4b91..7bd2ddb 100644 --- a/chloro/phyll/fields.py +++ b/chloro/phyll/fields.py @@ -14,9 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.conf import settings - import ckeditor.fields +from django.conf import settings class RichTextField(ckeditor.fields.RichTextField): @@ -28,12 +27,12 @@ class RichTextField(ckeditor.fields.RichTextField): 'external_plugin_resources': self.external_plugin_resources, } defaults.update(kwargs) - return super(RichTextField, self).formfield(**defaults) + return super().formfield(**defaults) class RichTextFormField(ckeditor.fields.RichTextFormField): def clean(self, value): - value = super(RichTextFormField, self).clean(value) + value = super().clean(value) if settings.LANGUAGE_CODE.startswith('fr-'): # apply some basic typographic rules value = value.replace('« ', '«\u202f') diff --git a/chloro/phyll/migrations/0001_initial.py b/chloro/phyll/migrations/0001_initial.py index 32c3af7..143385d 100644 --- a/chloro/phyll/migrations/0001_initial.py +++ b/chloro/phyll/migrations/0001_initial.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.17 on 2019-12-29 13:29 -from __future__ import unicode_literals -import chloro.phyll.fields -from django.db import migrations, models import taggit.managers +from django.db import migrations, models + +import chloro.phyll.fields class Migration(migrations.Migration): diff --git a/chloro/phyll/migrations/0002_auto_20191229_1932.py b/chloro/phyll/migrations/0002_auto_20191229_1932.py index 0620b4d..d9e83e5 100644 --- a/chloro/phyll/migrations/0002_auto_20191229_1932.py +++ b/chloro/phyll/migrations/0002_auto_20191229_1932.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.17 on 2019-12-29 18:32 -from __future__ import unicode_literals from django.db import migrations diff --git a/chloro/phyll/migrations/0003_note_published.py b/chloro/phyll/migrations/0003_note_published.py index 7c5f05e..f13495b 100644 --- a/chloro/phyll/migrations/0003_note_published.py +++ b/chloro/phyll/migrations/0003_note_published.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.17 on 2019-12-29 18:39 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/chloro/phyll/urls.py b/chloro/phyll/urls.py index 6de4516..bc58fbd 100644 --- a/chloro/phyll/urls.py +++ b/chloro/phyll/urls.py @@ -14,12 +14,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import ckeditor.views as ckeditor_views from django.conf.urls import url from django.contrib.admin.views.decorators import staff_member_required from django.views.decorators.cache import never_cache -import ckeditor.views as ckeditor_views - from . import views urlpatterns = [ diff --git a/chloro/phyll/views.py b/chloro/phyll/views.py index e67a1bc..b2fcbe2 100644 --- a/chloro/phyll/views.py +++ b/chloro/phyll/views.py @@ -21,13 +21,12 @@ from django.conf import settings from django.contrib.syndication.views import Feed from django.core.exceptions import PermissionDenied from django.core.files.storage import default_storage -from django.http import HttpResponse, Http404, JsonResponse +from django.http import Http404, HttpResponse, JsonResponse from django.utils.feedgenerator import Atom1Feed from django.utils.text import slugify from django.views import View from django.views.decorators.csrf import csrf_exempt -from django.views.generic import CreateView, DeleteView, DetailView, ListView, UpdateView, TemplateView - +from django.views.generic import CreateView, DeleteView, DetailView, ListView, TemplateView, UpdateView from sorl.thumbnail.shortcuts import get_thumbnail from .models import Note @@ -49,7 +48,7 @@ class NoteView(DetailView): raise Http404() if not note.published and not request.user.is_staff: raise PermissionDenied() - return super(NoteView, self).get(request, *args, **kwargs) + return super().get(request, *args, **kwargs) class NoteEditView(UpdateView): @@ -83,7 +82,7 @@ class HomeView(TemplateView): template_name = 'phyll/home.html' def get_context_data(self, **kwargs): - context = super(HomeView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) context['posts'] = Note.objects.filter(published=True).order_by('-creation_timestamp')[:5] context['recent_changes'] = Note.objects.filter(published=True).order_by('-last_update_timestamp') return context @@ -93,7 +92,7 @@ class ArchivesView(ListView): model = Note def get_queryset(self): - qs = super(ArchivesView, self).get_queryset() + qs = super().get_queryset() if not self.request.user.is_staff: qs = qs.filter(published=True) return qs @@ -111,7 +110,7 @@ class ListOnTagView(ListView): class Atom1FeedWithBaseXml(Atom1Feed): def root_attributes(self): - root_attributes = super(Atom1FeedWithBaseXml, self).root_attributes() + root_attributes = super().root_attributes() scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(self.feed['feed_url']) root_attributes['xml:base'] = urllib.parse.urlunparse((scheme, netloc, '/', params, query, fragment)) return root_attributes @@ -125,7 +124,7 @@ class AtomFeed(Feed): def get_object(self, request, *args, **kwargs): self.sub = kwargs.get('sub', 'default') - return super(AtomFeed, self).get_object(request, *args, **kwargs) + return super().get_object(request, *args, **kwargs) def items(self): qs = Note.objects.filter(published=True) diff --git a/debian/control b/debian/control index 2d171ec..09f4c0e 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper-compat (= 12), python3-all, python3-django, python3-setuptools, - sassc + sassc, Standards-Version: 3.9.1 Package: chloro diff --git a/setup.py b/setup.py index c11cbb8..01bf6b6 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,16 @@ #! /usr/bin/env python3 -# -*- coding: utf-8 -*- import os import re import subprocess import sys - -from setuptools.command.install_lib import install_lib as _install_lib +from distutils.cmd import Command from distutils.command.build import build as _build from distutils.command.sdist import sdist -from distutils.cmd import Command from distutils.spawn import find_executable -from setuptools import setup, find_packages + +from setuptools import find_packages, setup +from setuptools.command.install_lib import install_lib as _install_lib class eo_sdist(sdist): @@ -31,7 +30,7 @@ def get_version(): tag exists, take 0.0- and add the length of the commit log. """ if os.path.exists('VERSION'): - with open('VERSION', 'r') as v: + with open('VERSION') as v: return v.read() if os.path.exists('.git'): p = subprocess.Popen(