🚨(backend) fix linter warnings

Recent updates of dev/ruff and dev/pylint dependencies led
to new linting warnings.

Pylint 3.2.0 introduced a new check `possibly-used-before-assignment`,
which ensures variables are defined regardless of conditional statements.

Some if/else branches were missing defaults. These have been fixed.
This commit is contained in:
lebaudantoine
2024-07-30 16:48:26 +02:00
committed by aleb_the_flash
parent c93e770704
commit daa125edf3
27 changed files with 34 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
"""Admin classes and registrations for core app.""" """Admin classes and registrations for core app."""
from django.contrib import admin from django.contrib import admin
from django.contrib.auth import admin as auth_admin from django.contrib.auth import admin as auth_admin
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _

View File

@@ -1,4 +1,5 @@
"""Meet core API endpoints""" """Meet core API endpoints"""
from django.conf import settings from django.conf import settings
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
@@ -22,6 +23,8 @@ def exception_handler(exc, context):
detail = exc.message detail = exc.message
elif hasattr(exc, "messages"): elif hasattr(exc, "messages"):
detail = exc.messages detail = exc.messages
else:
detail = ""
exc = drf_exceptions.ValidationError(detail=detail) exc = drf_exceptions.ValidationError(detail=detail)

View File

@@ -1,4 +1,5 @@
"""Permission handlers for the Meet core app.""" """Permission handlers for the Meet core app."""
from rest_framework import permissions from rest_framework import permissions
from ..models import RoleChoices from ..models import RoleChoices

View File

@@ -1,4 +1,5 @@
"""Client serializers for the Meet core app.""" """Client serializers for the Meet core app."""
from django.conf import settings from django.conf import settings
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _

View File

@@ -1,4 +1,5 @@
"""API endpoints""" """API endpoints"""
import uuid import uuid
from django.conf import settings from django.conf import settings

View File

@@ -1,6 +1,7 @@
""" """
Core application enums declaration Core application enums declaration
""" """
from django.conf import global_settings, settings from django.conf import global_settings, settings
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _

View File

@@ -2,6 +2,7 @@
""" """
Core application factories Core application factories
""" """
from django.conf import settings from django.conf import settings
from django.contrib.auth.hashers import make_password from django.contrib.auth.hashers import make_password
from django.utils.text import slugify from django.utils.text import slugify

View File

@@ -1,6 +1,7 @@
""" """
Declare and configure the models for the Meet core application Declare and configure the models for the Meet core application
""" """
import uuid import uuid
from logging import getLogger from logging import getLogger

View File

@@ -92,9 +92,12 @@ def test_models_oidc_user_getter_invalid_token(django_assert_num_queries, monkey
monkeypatch.setattr(OIDCAuthenticationBackend, "get_userinfo", get_userinfo_mocked) monkeypatch.setattr(OIDCAuthenticationBackend, "get_userinfo", get_userinfo_mocked)
with django_assert_num_queries(0), pytest.raises( with (
SuspiciousOperation, django_assert_num_queries(0),
match="User info contained no recognizable user identification", pytest.raises(
SuspiciousOperation,
match="User info contained no recognizable user identification",
),
): ):
klass.get_or_create_user(access_token="test-token", id_token=None, payload=None) klass.get_or_create_user(access_token="test-token", id_token=None, payload=None)

View File

@@ -1,4 +1,5 @@
"""Fixtures for tests in the Meet core application""" """Fixtures for tests in the Meet core application"""
from unittest import mock from unittest import mock
import pytest import pytest

View File

@@ -1,6 +1,7 @@
""" """
Test rooms API endpoints in the Meet core app: create. Test rooms API endpoints in the Meet core app: create.
""" """
import pytest import pytest
from rest_framework.test import APIClient from rest_framework.test import APIClient

View File

@@ -1,6 +1,7 @@
""" """
Test rooms API endpoints in the Meet core app: delete. Test rooms API endpoints in the Meet core app: delete.
""" """
import pytest import pytest
from rest_framework.test import APIClient from rest_framework.test import APIClient

View File

@@ -1,6 +1,7 @@
""" """
Test rooms API endpoints in the Meet core app: list. Test rooms API endpoints in the Meet core app: list.
""" """
from unittest import mock from unittest import mock
import pytest import pytest

View File

@@ -1,6 +1,7 @@
""" """
Test rooms API endpoints in the Meet core app: retrieve. Test rooms API endpoints in the Meet core app: retrieve.
""" """
import random import random
from unittest import mock from unittest import mock

View File

@@ -1,6 +1,7 @@
""" """
Test rooms API endpoints in the Meet core app: update. Test rooms API endpoints in the Meet core app: update.
""" """
import random import random
import pytest import pytest

View File

@@ -1,6 +1,7 @@
""" """
Test suite for generated openapi schema. Test suite for generated openapi schema.
""" """
import json import json
from io import StringIO from io import StringIO

View File

@@ -1,6 +1,7 @@
""" """
Test resource accesses API endpoints in the Meet core app. Test resource accesses API endpoints in the Meet core app.
""" """
import random import random
from unittest import mock from unittest import mock
from uuid import uuid4 from uuid import uuid4

View File

@@ -1,6 +1,7 @@
""" """
Test users API endpoints in the Meet core app. Test users API endpoints in the Meet core app.
""" """
import pytest import pytest
from rest_framework.test import APIClient from rest_framework.test import APIClient

View File

@@ -1,6 +1,7 @@
""" """
Unit tests for the ResourceAccess model with user Unit tests for the ResourceAccess model with user
""" """
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
import pytest import pytest

View File

@@ -1,6 +1,7 @@
""" """
Unit tests for the Room model Unit tests for the Room model
""" """
from django.contrib.auth.models import AnonymousUser from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError

View File

@@ -1,6 +1,7 @@
""" """
Unit tests for the User model Unit tests for the User model
""" """
from unittest import mock from unittest import mock
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError

View File

@@ -1,4 +1,5 @@
"""URL configuration for the core app.""" """URL configuration for the core app."""
from django.conf import settings from django.conf import settings
from django.urls import include, path from django.urls import include, path

View File

@@ -1,6 +1,7 @@
""" """
Utils functions used in the core app Utils functions used in the core app
""" """
from typing import Optional from typing import Optional
from uuid import uuid4 from uuid import uuid4

View File

@@ -1,4 +1,5 @@
"""Management user to create a superuser.""" """Management user to create a superuser."""
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand

View File

@@ -2,6 +2,7 @@
""" """
meet's sandbox management script. meet's sandbox management script.
""" """
import os import os
import sys import sys

View File

@@ -1,4 +1,5 @@
"""Meet celery configuration file.""" """Meet celery configuration file."""
import os import os
from celery import Celery from celery import Celery

View File

@@ -9,6 +9,7 @@ https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
import json import json
import os import os