Skip to content

Commit

Permalink
🚨(backend) fix lint ruff lint
Browse files Browse the repository at this point in the history
Lint codebase with ruff 0.3.0
  • Loading branch information
jbpenrath committed Mar 5, 2024
1 parent 9d84a5b commit 576d20c
Show file tree
Hide file tree
Showing 224 changed files with 384 additions and 105 deletions.
1 change: 1 addition & 0 deletions src/backend/joanie/badges/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure the models for the badges part
"""

from functools import lru_cache

from django.db import models
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/celery_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Joanie celery configuration file."""

import os

from celery import Celery
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/client_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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.urls import include, path, re_path

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""API for the joanie project."""

from http import HTTPStatus

from django.core.exceptions import ValidationError as DjangoValidationError
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/api/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Admin API Endpoints
"""

from http import HTTPStatus

from django.core.exceptions import ValidationError
Expand Down
3 changes: 2 additions & 1 deletion src/backend/joanie/core/api/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base API classes for the Joanie project. """
"""Base API classes for the Joanie project."""

from rest_framework import viewsets


Expand Down
7 changes: 4 additions & 3 deletions src/backend/joanie/core/api/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Client API endpoints
"""

# pylint: disable=too-many-ancestors, too-many-lines
import io
import uuid
Expand Down Expand Up @@ -470,9 +471,9 @@ def invoice(self, request, pk=None): # pylint: disable=no-self-use, invalid-nam
response = HttpResponse(
invoice_pdf_bytes, content_type="application/pdf", status=HTTPStatus.OK
)
response[
"Content-Disposition"
] = f"attachment; filename={invoice.reference}.pdf;"
response["Content-Disposition"] = (
f"attachment; filename={invoice.reference}.pdf;"
)

return response

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/api/remote_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Remote endpoints API for other servers.
"""

from http import HTTPStatus

from django.http import JsonResponse
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Joanie Core application"""

from django.apps import AppConfig
from django.db.models.signals import m2m_changed, post_save
from django.utils.translation import gettext_lazy as _
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/authentication.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Authentication for joanie's core app."""

from django.conf import settings
from django.utils.functional import SimpleLazyObject
from django.utils.translation import get_supported_language_variant
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/enums.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Core application enums declaration
"""

from django.conf import global_settings, settings
from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Core application factories
"""

import hashlib
import json
import random
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/fields/multiselect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A multi select field where the array of values is stored as a comma separated string."""

from django.core import checks, exceptions, validators
from django.db import models
from django.forms import MultipleChoiceField, widgets
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/filters/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Admin API Resource Filters
"""

from typing import List

from django.conf import settings
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/filters/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Client API Resource Filters
"""

from typing import List

from django.db.models import Q
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Core application forms declaration
"""

from django import forms
from django.contrib.admin import widgets

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helpers that can be useful throughout Joanie's core app
"""

from joanie.core import enums


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Management command to generate all pending certificates."""

import logging

from django.core.management import BaseCommand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Management command to synchronize course runs or equivalent course runs."""

import logging
from uuid import UUID

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/middleware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Middleware for joanie project."""

import time

from dockerflow.django.middleware import DockerflowMiddleware
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Make models.py a module containing one file per model as it was getting too long."""

# pylint: disable=wildcard-import
from .accounts import *
from .certifications import *
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/accounts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure the models for the customers part
"""

import django.contrib.auth.models as auth_models
from django.conf import settings
from django.core.exceptions import ValidationError
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
In this base model, we activate generic behaviours that apply to all our models and enforce
checks and validation that go further than what Django is doing.
"""

import uuid
from itertools import chain

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/certifications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure the models for the certifications part
"""

import logging

from django.conf import settings
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/contracts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure the models for Joanie's contracts
"""

import logging
import textwrap
from datetime import timedelta
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/course_wishes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure models for course wishes
"""

from django.db import models
from django.utils.translation import gettext_lazy as _

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/courses.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure the models for the courses part
"""

import itertools
import logging
from collections.abc import Mapping
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/products.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Declare and configure the models for the product / order part
"""

import itertools
import logging
from collections import defaultdict
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/models/site.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Site extension models for the Joanie project."""

import textwrap

from django.contrib.sites.models import Site
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/pagination.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pagination used by django rest framework."""

from rest_framework.pagination import PageNumberPagination


Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Permission handlers for joanie's core app."""

from django.conf import settings

from rest_framework import permissions
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/serializers/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=too-many-lines
"""Admin serializers for Joanie Core app."""

from django.conf import settings

from drf_spectacular.utils import extend_schema_serializer
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/serializers/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base Serializer classes for the Joanie project."""

from django.conf import settings
from django.core.cache import cache

Expand Down
9 changes: 5 additions & 4 deletions src/backend/joanie/core/serializers/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Client serializers for Joanie Core app."""

# pylint: disable=too-many-lines
from django.conf import settings
from django.utils.translation import get_language
Expand Down Expand Up @@ -983,10 +984,10 @@ def validate(self, attrs):
errors = {}
if course_product_relation_id:
try:
attrs[
"course_product_relation"
] = models.CourseProductRelation.objects.get(
pk=course_product_relation_id
attrs["course_product_relation"] = (
models.CourseProductRelation.objects.get(
pk=course_product_relation_id
)
)
except models.CourseProductRelation.DoesNotExist:
errors["course_product_relation_id"] = (
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/serializers/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom serializer fields."""

from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import extend_schema_field
from easy_thumbnails.alias import aliases
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helpers that can be useful throughout Joanie's core app
"""

import logging

from django.core.exceptions import ValidationError
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/storages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module containing specific storages."""

from django.conf import settings

from storages.backends.s3 import S3Storage
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Celery tasks for the `core` app of Joanie"""

from logging import getLogger

from django.core.management import call_command
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/templatetags/extra_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom template tags for the core application of Joanie."""

import math

from django import template
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utils that can be useful throughout Joanie's core app
"""

import base64
import collections.abc
import json
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/utils/contract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility to generate a ZIP archive of PDF bytes files for contracts that are signed"""

import io
import zipfile
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/utils/contract_definition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility to `generate document context` data"""

from django.conf import settings
from django.contrib.sites.models import Site
from django.utils.translation import gettext as _
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/utils/course_run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utility methods for Course Run on enrollments metrics and orders made.
"""

import logging

from django.core.exceptions import ValidationError
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/utils/issuers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils that can be useful throughout Joanie's core app for document issuers"""

from pathlib import Path

from django.template import Context
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/utils/webhooks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utils that can be useful throughout Joanie's core app to synchronize data with other services
"""

import hashlib
import hmac
import json
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Views of the ``core`` app of the Joanie project."""

from .certificate import *
from .redirect import *
1 change: 1 addition & 0 deletions src/backend/joanie/core/views/certificate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Certificate views for the Joanie core app."""

import base64

from django.contrib.sites.models import Site
Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/core/views/redirect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Redirect views of the `core`app."""

from django.conf import settings
from django.views.generic.base import RedirectView

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/debug/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""All debug views of the `debug`app."""

import base64
import datetime
from logging import getLogger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ruff: noqa: S311, PLR0913, PLR0915
"""Management command to initialize some fake data (products, courses and course runs)"""

import random

from django.conf import settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Management command to generate user JWT tokens"""

import json
from datetime import datetime, timedelta

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/edx_imports/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Check the environment variables and database connections required for the import tasks.
"""

from http import HTTPStatus
from logging import getLogger

Expand Down
1 change: 1 addition & 0 deletions src/backend/joanie/edx_imports/edx_factories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Factory classes for generating fake data for testing."""

import random

import factory
Expand Down
Loading

0 comments on commit 576d20c

Please sign in to comment.