From 3b2c713a8e16292f54546a63ee19e39e2a9fa38c Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 1 Mar 2023 15:07:21 +0100 Subject: [PATCH] misc: apply pre-commit-hooks (#74981) --- debian/control | 9 +++--- .../minint_brexit/migrations/0001_initial.py | 2 -- passerelle_minint/minint_brexit/models.py | 7 ++--- .../minint_maarch/migrations/0001_initial.py | 2 -- .../templates/minint_maarch/detail.html | 28 +++++++++---------- passerelle_minint/minint_maarch/urls.py | 12 ++++---- passerelle_minint/minint_maarch/views.py | 6 ++-- .../minint_seisin/migrations/0001_initial.py | 2 -- .../templates/minint_seisin/detail.html | 20 ++++++------- passerelle_minint/minint_seisin/urls.py | 10 ++++--- passerelle_minint/minint_seisin/views.py | 2 +- setup.py | 2 +- tests/utils.py | 2 +- 13 files changed, 50 insertions(+), 54 deletions(-) diff --git a/debian/control b/debian/control index 09da392..4b896bc 100644 --- a/debian/control +++ b/debian/control @@ -2,12 +2,13 @@ Source: passerelle-minint Maintainer: Entr'ouvert Section: python Priority: optional -Build-Depends: dh-python, debhelper-compat (= 12), python3-setuptools, python3-all +Build-Depends: debhelper-compat (= 12), + dh-python, + python3-all, + python3-setuptools, Standards-Version: 3.9.1 Package: python3-passerelle-minint Architecture: all -Depends: ${misc:Depends}, - ${python3:Depends}, - python3-suds +Depends: python3-suds, ${misc:Depends}, ${python3:Depends} Description: Passerelle MinInt Connectors (Python 3) diff --git a/passerelle_minint/minint_brexit/migrations/0001_initial.py b/passerelle_minint/minint_brexit/migrations/0001_initial.py index 3ae99bd..bae15fb 100644 --- a/passerelle_minint/minint_brexit/migrations/0001_initial.py +++ b/passerelle_minint/minint_brexit/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2020-05-04 13:59 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/passerelle_minint/minint_brexit/models.py b/passerelle_minint/minint_brexit/models.py index 2108b4c..44b4480 100644 --- a/passerelle_minint/minint_brexit/models.py +++ b/passerelle_minint/minint_brexit/models.py @@ -1,4 +1,3 @@ -# coding=utf-8 import requests from django.db import models from django.utils.http import urlquote @@ -37,13 +36,13 @@ class Brexit(BaseResource): try: response = self.requests.get(self.url + '/%s/%s' % (num, email), verify=False) except requests.RequestException as e: - raise APIError(u'API-maarch connection error: %s' % exception_to_text(e), data=[]) + raise APIError('API-maarch connection error: %s' % exception_to_text(e), data=[]) try: data = response.json() except ValueError as e: content = repr(response.content[:1000]) raise APIError( - u'API-maarch returned non-JSON content with status %s: %s' % (response.status_code, content), + 'API-maarch returned non-JSON content with status %s: %s' % (response.status_code, content), data={ 'status_code': response.status_code, 'exception': exception_to_text(e), @@ -57,7 +56,7 @@ class Brexit(BaseResource): 'err_desc': data.get('message', 'not-found'), } raise APIError( - u'API-maarch returned a non 200 status %s: %s' % (response.status_code, data), + 'API-maarch returned a non 200 status %s: %s' % (response.status_code, data), data={ 'status_code': response.status_code, 'content': data, diff --git a/passerelle_minint/minint_maarch/migrations/0001_initial.py b/passerelle_minint/minint_maarch/migrations/0001_initial.py index 44bb7f0..6eab5ee 100644 --- a/passerelle_minint/minint_maarch/migrations/0001_initial.py +++ b/passerelle_minint/minint_maarch/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2020-05-01 00:16 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/passerelle_minint/minint_maarch/templates/minint_maarch/detail.html b/passerelle_minint/minint_maarch/templates/minint_maarch/detail.html index 7eed0c9..edd8932 100644 --- a/passerelle_minint/minint_maarch/templates/minint_maarch/detail.html +++ b/passerelle_minint/minint_maarch/templates/minint_maarch/detail.html @@ -5,21 +5,21 @@ {% endblock %} {% block endpoints %} - + {% endblock %} {% block security %} -

-{% trans 'Access is limited to the following API users:' %} -

-{% access_rights_table resource=object permission='can_access' %} +

+ {% trans 'Access is limited to the following API users:' %} +

+ {% access_rights_table resource=object permission='can_access' %} {% endblock %} diff --git a/passerelle_minint/minint_maarch/urls.py b/passerelle_minint/minint_maarch/urls.py index 012262a..6764b2d 100644 --- a/passerelle_minint/minint_maarch/urls.py +++ b/passerelle_minint/minint_maarch/urls.py @@ -14,14 +14,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.conf.urls import include, url +from django.urls import re_path from .views import * urlpatterns = [ - url(r'^(?P[\w,-]+)/$', MaarchDetailView.as_view(), name='minint-maarch-view'), - url(r'^(?P[\w,-]+)/ping/$', PingView.as_view(), name='minint-maarch-ping'), - url(r'^(?P[\w,-]+)/resource/$', ResourceView.as_view(), name='minint-maarch-resource'), - url(r'^(?P[\w,-]+)/attachment/$', AttachmentView.as_view(), name='minint-maarch-attachment'), - url(r'^(?P[\w,-]+)/debug/$', DebugView.as_view(), name='minint-maarch-debug'), + re_path(r'^(?P[\w,-]+)/$', MaarchDetailView.as_view(), name='minint-maarch-view'), + re_path(r'^(?P[\w,-]+)/ping/$', PingView.as_view(), name='minint-maarch-ping'), + re_path(r'^(?P[\w,-]+)/resource/$', ResourceView.as_view(), name='minint-maarch-resource'), + re_path(r'^(?P[\w,-]+)/attachment/$', AttachmentView.as_view(), name='minint-maarch-attachment'), + re_path(r'^(?P[\w,-]+)/debug/$', DebugView.as_view(), name='minint-maarch-debug'), ] diff --git a/passerelle_minint/minint_maarch/views.py b/passerelle_minint/minint_maarch/views.py index b6aedeb..9c45623 100644 --- a/passerelle_minint/minint_maarch/views.py +++ b/passerelle_minint/minint_maarch/views.py @@ -99,7 +99,7 @@ class PingView(DetailView): class ResourceView(DetailView): @method_decorator(csrf_exempt) def dispatch(self, *args, **kwargs): - return super(ResourceView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) @utils.protected_api('can_access') def post(self, request, *args, **kwargs): @@ -398,7 +398,7 @@ class ResourceView(DetailView): class AttachmentView(DetailView): @method_decorator(csrf_exempt) def dispatch(self, *args, **kwargs): - return super(AttachmentView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) @utils.protected_api('can_access') def post(self, request, *args, **kwargs): @@ -513,7 +513,7 @@ class AttachmentView(DetailView): class DebugView(DetailView): @method_decorator(csrf_exempt) def dispatch(self, *args, **kwargs): - return super(DebugView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) @utils.protected_api('can_access') def post(self, request, *args, **kwargs): diff --git a/passerelle_minint/minint_seisin/migrations/0001_initial.py b/passerelle_minint/minint_seisin/migrations/0001_initial.py index a902122..f132720 100644 --- a/passerelle_minint/minint_seisin/migrations/0001_initial.py +++ b/passerelle_minint/minint_seisin/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2020-05-01 00:17 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/passerelle_minint/minint_seisin/templates/minint_seisin/detail.html b/passerelle_minint/minint_seisin/templates/minint_seisin/detail.html index ac8832a..a10c082 100644 --- a/passerelle_minint/minint_seisin/templates/minint_seisin/detail.html +++ b/passerelle_minint/minint_seisin/templates/minint_seisin/detail.html @@ -5,17 +5,17 @@ {% endblock %} {% block endpoints %} - + {% endblock %} {% block security %} -

-{% trans 'Access is limited to the following API users:' %} -

-{% access_rights_table resource=object permission='can_access' %} +

+ {% trans 'Access is limited to the following API users:' %} +

+ {% access_rights_table resource=object permission='can_access' %} {% endblock %} diff --git a/passerelle_minint/minint_seisin/urls.py b/passerelle_minint/minint_seisin/urls.py index 3937271..430f203 100644 --- a/passerelle_minint/minint_seisin/urls.py +++ b/passerelle_minint/minint_seisin/urls.py @@ -14,12 +14,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.conf.urls import include, url +from django.urls import re_path from .views import * urlpatterns = [ - url(r'^(?P[\w,-]+)/$', SeisinManagementDetailView.as_view(), name='minint-seisin-by-email-view'), - url(r'^(?P[\w,-]+)/ping/$', PingView.as_view(), name='minint-seisin-by-email-ping'), - url(r'^(?P[\w,-]+)/resource/$', ResourceView.as_view(), name='minint-seisin-by-email-resource'), + re_path( + r'^(?P[\w,-]+)/$', SeisinManagementDetailView.as_view(), name='minint-seisin-by-email-view' + ), + re_path(r'^(?P[\w,-]+)/ping/$', PingView.as_view(), name='minint-seisin-by-email-ping'), + re_path(r'^(?P[\w,-]+)/resource/$', ResourceView.as_view(), name='minint-seisin-by-email-resource'), ] diff --git a/passerelle_minint/minint_seisin/views.py b/passerelle_minint/minint_seisin/views.py index c6daee5..a5858de 100644 --- a/passerelle_minint/minint_seisin/views.py +++ b/passerelle_minint/minint_seisin/views.py @@ -58,7 +58,7 @@ class PingView(DetailView): class ResourceView(DetailView): @method_decorator(csrf_exempt) def dispatch(self, *args, **kwargs): - return super(ResourceView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) @utils.protected_api('can_access') def post(self, request, *args, **kwargs): diff --git a/setup.py b/setup.py index 98a267c..4f05b54 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ def get_version(): tag exists, take 0.0- and add the length of the commit log. ''' if os.path.exists('VERSION'): - version_file = open('VERSION', 'r') + version_file = open('VERSION') version = version_file.read() version_file.close() return version diff --git a/tests/utils.py b/tests/utils.py index f018215..e9897f2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,8 +1,8 @@ import json import urllib.parse +from unittest import mock import httmock -import mock from django.contrib.contenttypes.models import ContentType from django.urls import reverse from passerelle.base.models import AccessRight, ApiUser