Fix formatting and resolve pre-commit errors

This commit is contained in:
Ghosts6 2024-10-19 20:10:57 +01:00
parent 1a50ea4f9d
commit f6ed811e97
7 changed files with 8 additions and 6 deletions

View File

@ -894,6 +894,7 @@ class AlphabeticFieldValidator:
if not re.match(r'^[A-Za-z ]*$', value): if not re.match(r'^[A-Za-z ]*$', value):
raise ValueError("This field must contain only alphabetic characters and spaces.") raise ValueError("This field must contain only alphabetic characters and spaces.")
class AlphanumericFieldValidator: class AlphanumericFieldValidator:
""" """
Custom validator to ensure the field contains only alphanumeric characters (letters and numbers). Custom validator to ensure the field contains only alphanumeric characters (letters and numbers).
@ -906,6 +907,7 @@ class AlphanumericFieldValidator:
if not re.match(r'^[A-Za-z0-9]*$', value): if not re.match(r'^[A-Za-z0-9]*$', value):
raise ValueError("This field must contain only alphanumeric characters (letters and numbers).") raise ValueError("This field must contain only alphanumeric characters (letters and numbers).")
class CustomLengthValidator: class CustomLengthValidator:
""" """
Custom validator to ensure the length of a string is within specified limits. Custom validator to ensure the length of a string is within specified limits.

View File

@ -172,6 +172,7 @@ class IsAuthenticatedOrReadOnly(BasePermission):
request.user.is_authenticated request.user.is_authenticated
) )
class IsAdminUserOrReadOnly(BasePermission): class IsAdminUserOrReadOnly(BasePermission):
""" """
Custom permission to only allow admin users to edit an object. Custom permission to only allow admin users to edit an object.

View File

@ -157,4 +157,4 @@ class OwnershipTestModel(models.Model):
title = models.CharField(max_length=100) title = models.CharField(max_length=100)
def __str__(self): def __str__(self):
return self.title return self.title

View File

@ -1141,6 +1141,7 @@ class TestAlphanumericField:
validator(value) validator(value)
assert str(excinfo.value) == "This field must be a string." assert str(excinfo.value) == "This field must be a string."
class TestCustomLengthField: class TestCustomLengthField:
""" """
Valid and invalid values for `CustomLengthValidator`. Valid and invalid values for `CustomLengthValidator`.

View File

@ -819,4 +819,4 @@ class PermissionTests(TestCase):
self.assertTrue(permission.has_object_permission(request, None, obj)) self.assertTrue(permission.has_object_permission(request, None, obj))
request.user = self.admin_user request.user = self.admin_user
self.assertTrue(permission.has_object_permission(request, None, obj)) self.assertTrue(permission.has_object_permission(request, None, obj))

View File

@ -1,8 +1,7 @@
from django.test import TestCase from django.test import TestCase
from rest_framework.status import ( from rest_framework.status import (
is_client_error, is_informational, is_redirect, is_server_error, is_client_error, is_informational, is_redirect, is_server_error, is_success
is_success
) )

View File

@ -10,8 +10,7 @@ from django.test import TestCase
from rest_framework import serializers from rest_framework import serializers
from rest_framework.exceptions import ValidationError from rest_framework.exceptions import ValidationError
from rest_framework.validators import ( from rest_framework.validators import (
BaseUniqueForValidator, UniqueTogetherValidator, UniqueValidator, BaseUniqueForValidator, UniqueTogetherValidator, UniqueValidator, qs_exists
qs_exists
) )