Skip to content

Commit

Permalink
🎨 fix isort and black related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-maykin committed Mar 19, 2024
1 parent b927f43 commit 5d030fa
Show file tree
Hide file tree
Showing 33 changed files with 109 additions and 63 deletions.
50 changes: 33 additions & 17 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up environment
uses: maykinmedia/setup-django-backend@v1
with:
python-version: '3.8'
- uses: isort/isort-action@v0.1.0
python-version: '3.10'
setup-node: 'no'
- uses: isort/isort-action@v1.1.0
with:
requirementsFiles: requirements/ci.txt
sortPaths: "src"
Expand All @@ -23,13 +25,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up environment
uses: maykinmedia/setup-django-backend@v1
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install -r requirements/ci.txt
python-version: '3.10'
setup-node: 'no'
- name: Run black
run: |
black --check src
Expand All @@ -39,13 +40,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up environment
uses: maykinmedia/setup-django-backend@v1
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install -r requirements/ci.txt
python-version: '3.10'
setup-node: 'no'
- name: Run flake8
id: flake8
run: |
flake8 src --ignore=E501,F405,W503,F401
flake8 src 2>&1 | tee flake8_output.txt
result_code=${PIPESTATUS[0]}
report="$(cat flake8_output.txt)"
report="${report//$'\n'/'%0A'}" # escape newlines
echo "FLAKE8_REPORT=${report}" >> $GITHUB_OUTPUT
exit $result_code
- name: Emit flake8 flake8 output
if: ${{ failure() }}
run: |
echo "${{ steps.flake8.outputs.FLAKE8_REPORT }}"
echo 'flake8 found some issues' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '| File | Line | Column | Issue |' >> $GITHUB_STEP_SUMMARY
echo '| :--- | ---- | ------ | :---- |' >> $GITHUB_STEP_SUMMARY
python ./bin/flake8_summary.py "${{ steps.flake8.outputs.FLAKE8_REPORT }}" >> $GITHUB_STEP_SUMMARY
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ skip_glob = **/migrations/**
known_django=django
known_first_party=sdg
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

; black compatible settings
[flake8]
; absolute maximum - more lenient than black's 88
max-line-length = 119
ignore = E501,E731,F405,W503
; "E501", # line too long (makes the `max-line-length = 119` unnecessary)
; "E731", # Assign lambda
; "F405", # name from * imports (because of the * imports in /conf)
; "W503", # Line break before binary operator
exclude = migrations,static,media,frontend
23 changes: 23 additions & 0 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ components:
type: string
format: uuid
readOnly: true
nullable: true
description: De identificatie die binnen deze API gebruikt wordt voor de
resource.
upnUri:
Expand Down Expand Up @@ -952,6 +953,7 @@ components:
description: Het label en de link naar de procedure.
productAanwezigToelichting:
type: string
default: ''
title: Aanwezig toelichting
description: Een optioneel veld om uit te leggen waarom het product niet
aanwezig is. Deze moet u alleen invullen als u het product niet levert
Expand Down Expand Up @@ -1266,6 +1268,9 @@ components:
te worden: `["9:00 - 18:00"]`'
PaginatedGeneriekProductList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -1286,6 +1291,9 @@ components:
$ref: '#/components/schemas/GeneriekProduct'
PaginatedLocatieList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -1306,6 +1314,9 @@ components:
$ref: '#/components/schemas/Locatie'
PaginatedLokaleOverheidList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -1326,6 +1337,9 @@ components:
$ref: '#/components/schemas/LokaleOverheid'
PaginatedProductList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -1346,6 +1360,9 @@ components:
$ref: '#/components/schemas/Product'
PaginatedProductVersieList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand All @@ -1366,6 +1383,9 @@ components:
$ref: '#/components/schemas/ProductVersie'
PaginatedProductenCatalogusList:
type: object
required:
- count
- results
properties:
count:
type: integer
Expand Down Expand Up @@ -1679,6 +1699,7 @@ components:
type: integer
maximum: 2147483647
minimum: 0
default: 1
description: Het versienummer van het product.
gemaaktOp:
type: string
Expand Down Expand Up @@ -1732,6 +1753,7 @@ components:
description: De organisatie die deze catalogus beheert.
isReferentieCatalogus:
type: boolean
default: false
description: Een boolean die aangeeft of de catalogus een referentie catalogus
betreft. Een referentie catalogus bevat geen echte productbeschrijvingen.
referentieCatalogus:
Expand All @@ -1747,6 +1769,7 @@ components:
type: integer
maximum: 2147483647
minimum: 0
default: 1
description: De versie van deze catalogus. Op dit moment heeft de waarde
geen betekenis.
producten:
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from django.contrib import admin, messages
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin as _UserAdmin
from django.utils.translation import gettext_lazy as _
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _

from allauth.account.models import EmailAddress
from django_otp.plugins.otp_totp.admin import TOTPDeviceAdmin
Expand Down
2 changes: 0 additions & 2 deletions src/sdg/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from secrets import compare_digest

from django import forms
from django.contrib.auth.forms import AuthenticationForm as _AuthenticationForm
from django.forms import inlineformset_factory
Expand Down
23 changes: 23 additions & 0 deletions src/sdg/accounts/migrations/0016_alter_userinvitation_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.11 on 2024-03-19 23:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("accounts", "0015_update_ontvangt_email"),
]

operations = [
migrations.AlterField(
model_name="userinvitation",
name="key",
field=models.CharField(
default="FznUE1li2Ldr5fvZC2QSyt9q5N7vs7nxOeAFN8ppUdDuG3mcgWOVKLMrGHT13TXR",
max_length=64,
unique=True,
verbose_name="key",
),
),
]
2 changes: 1 addition & 1 deletion src/sdg/accounts/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .csrf import csrf_failure
from .csrf import csrf_failure # noqa
2 changes: 1 addition & 1 deletion src/sdg/api/filters/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sdg.core.constants import DoelgroepChoices, TaalChoices
from sdg.core.models import ProductenCatalogus
from sdg.organisaties.models import LokaleOverheid, Lokatie as Locatie
from sdg.producten.models import GeneriekProduct, Product
from sdg.producten.models import Product


class ProductenCatalogusFilterSet(FilterSet):
Expand Down
2 changes: 1 addition & 1 deletion src/sdg/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.conf import settings

from rest_framework.permissions import SAFE_METHODS, BasePermission
from rest_framework.permissions import BasePermission
from vng_api_common.permissions import bypass_permissions

from sdg.api.models import Token
Expand Down
1 change: 0 additions & 1 deletion src/sdg/api/serializers/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers

Expand Down
1 change: 0 additions & 1 deletion src/sdg/api/tests/factories/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from factory.django import DjangoModelFactory

from sdg.api.models import Token, TokenAuthorization
from sdg.core.tests.factories.logius import OverheidsorganisatieFactory
from sdg.organisaties.tests.factories.overheid import LokaleOverheidFactory


Expand Down
3 changes: 0 additions & 3 deletions src/sdg/api/views/core.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from django.db.models import Prefetch

from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_view
from rest_framework import viewsets

from sdg.api.filters import ProductenCatalogusFilterSet
from sdg.api.serializers import ProductenCatalogusSerializer
from sdg.core.models import ProductenCatalogus
from sdg.producten.models import Product


@extend_schema_view(
Expand Down
1 change: 0 additions & 1 deletion src/sdg/conf/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys

from django.urls import reverse_lazy

Expand Down
2 changes: 1 addition & 1 deletion src/sdg/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CoreConfig(AppConfig):
]

def ready(self):
from .checks import localized_form_field_check
from .checks import localized_form_field_check # noqa

post_migrate.connect(register_project_models, sender=self)
post_migrate.connect(load_app_fixtures, sender=self)
1 change: 0 additions & 1 deletion src/sdg/core/constants/product.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.conf import settings
from django.utils.translation import gettext_lazy as _

from djchoices import ChoiceItem, DjangoChoices
Expand Down
2 changes: 0 additions & 2 deletions src/sdg/core/tests/factories/logius.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from datetime import datetime

import factory
from factory.django import DjangoModelFactory

Expand Down
3 changes: 1 addition & 2 deletions src/sdg/core/tests/test_cms_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from django.test import override_settings
from django.urls import reverse

from sdg.core.tests.utils import WebTest

from sdg.accounts.tests.factories import RoleFactory, SuperUserFactory
from sdg.core.tests.factories.catalogus import ProductenCatalogusFactory
from sdg.core.tests.factories.logius import OverheidsorganisatieFactory
from sdg.core.tests.utils import WebTest
from sdg.organisaties.tests.factories.overheid import LokaleOverheidFactory


Expand Down
3 changes: 1 addition & 2 deletions src/sdg/core/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from django.test import TestCase

from sdg.core.tests.utils import WebTest

from sdg.accounts.tests.factories import UserFactory
from sdg.conf.types.organization import (
OrganizationTypeConfiguration,
available_org_types,
)
from sdg.core.models import SiteConfiguration
from sdg.core.tests.utils import WebTest


class SiteConfigurationTests(WebTest):
Expand Down
3 changes: 1 addition & 2 deletions src/sdg/core/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from django.test import override_settings
from django.urls import reverse

from sdg.core.tests.utils import WebTest

from sdg.accounts.tests.factories import RoleFactory, UserFactory
from sdg.conf.utils import org_type_cfg
from sdg.core.tests.utils import WebTest

HOME_URL = "core:home"
CARD_SELECTOR = ".cards__card"
Expand Down
1 change: 0 additions & 1 deletion src/sdg/core/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django_webtest import WebTest as DjangoWebTest

from maykin_2fa.test import disable_admin_mfa as disable_mfa


Expand Down
2 changes: 1 addition & 1 deletion src/sdg/core/views/home.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.models import Q, Subquery
from django.db.models import Subquery
from django.shortcuts import redirect
from django.views.generic import TemplateView

Expand Down
1 change: 0 additions & 1 deletion src/sdg/core/views/mixins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.views.generic.base import ContextMixin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from django.conf import settings
from django.core.mail import send_mail
from django.core.management import BaseCommand
from django.db.models import Q
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from django.utils.timezone import now
from django.template.loader import render_to_string

from dateutil.relativedelta import relativedelta

Expand Down
3 changes: 1 addition & 2 deletions src/sdg/organisaties/tests/test_bevoegde_organisaties.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.urls import reverse_lazy

from sdg.core.tests.utils import WebTest

from sdg.accounts.tests.factories import RoleFactory, UserFactory
from sdg.core.tests.factories.logius import OverheidsorganisatieFactory
from sdg.core.tests.utils import WebTest
from sdg.organisaties.tests.factories.overheid import LokaleOverheidFactory


Expand Down
3 changes: 1 addition & 2 deletions src/sdg/organisaties/tests/test_invitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from django.urls import reverse
from django.utils.translation import gettext as _

from sdg.core.tests.utils import WebTest

from sdg.accounts.models import UserInvitation
from sdg.accounts.tests.factories import RoleFactory, UserFactory
from sdg.conf.utils import org_type_cfg
from sdg.core.tests.utils import WebTest
from sdg.organisaties.tests.factories.overheid import LokaleOverheidFactory

INVITATION_URL = "organisaties:roles:invitation_create"
Expand Down
Loading

0 comments on commit 5d030fa

Please sign in to comment.