🚨(linter) add missing docstrings

Title says all there is to say…
This commit is contained in:
Laurent Bossavit
2024-10-25 14:59:02 +02:00
committed by Laurent Bossavit
parent 3934a0bc28
commit 1d1f5cfbb6
32 changed files with 38 additions and 4 deletions

View File

@@ -0,0 +1 @@
"""Core root module."""

View File

@@ -148,8 +148,8 @@ class InvitationAdmin(admin.ModelAdmin):
)
def get_readonly_fields(self, request, obj=None):
"""Mark all fields read only, i.e. disable update."""
if obj:
# all fields read only = disable update
return self.fields
return self.readonly_fields
@@ -162,5 +162,6 @@ class InvitationAdmin(admin.ModelAdmin):
return super().change_view(request, object_id, extra_context=extra_context)
def save_model(self, request, obj, form, change):
"""Fill in current logged-in user as issuer."""
obj.issuer = request.user
obj.save()

View File

@@ -12,13 +12,13 @@ class IsAuthenticated(permissions.BasePermission):
"""
def has_permission(self, request, view):
"""Check auth token first."""
return bool(request.auth) if request.auth else request.user.is_authenticated
class IsSelf(IsAuthenticated):
"""
Allows access only to authenticated users. Alternative method checking the presence
of the auth token to avoid hitting the database.
Allows access only to user's own data.
"""
def has_object_permission(self, request, view, obj):

View File

@@ -34,6 +34,8 @@ class DynamicFieldsModelSerializer(serializers.ModelSerializer):
"""
def __init__(self, *args, **kwargs):
"""Pass arguments to superclass except 'fields', then drop fields not listed therein."""
# Don't pass the 'fields' arg up to the superclass
fields = kwargs.pop("fields", None)

View File

@@ -340,6 +340,7 @@ class TeamAccessViewSet(
return context
def get_serializer_class(self):
"""Chooses list or detail serializer according to the action."""
if self.action in {"list", "retrieve"}:
return self.list_serializer_class
return self.detail_serializer_class

View File

@@ -0,0 +1 @@
"""Authentication module."""

View File

@@ -0,0 +1 @@
"""Backend resource server module."""

View File

@@ -19,6 +19,7 @@ class ResourceServerAuthentication(OIDCAuthentication):
"""Authenticate clients using the token received from the authorization server."""
def __init__(self):
"""Require authentication to be configured in order to instantiate."""
super().__init__()
try:
@@ -40,7 +41,7 @@ class ResourceServerAuthentication(OIDCAuthentication):
def get_access_token(self, request):
"""Retrieve and decode the access token from the request.
This method overcharges the 'get_access_token' method from the parent class,
This method overrides the 'get_access_token' method from the parent class,
to support service providers that would base64 encode the bearer token.
"""

View File

@@ -33,6 +33,7 @@ class ResourceServerBackend:
# pylint: disable=too-many-instance-attributes
def __init__(self, authorization_server_client):
"""Require client_id, client_secret set and authorization_server_client provided."""
# pylint: disable=invalid-name
self.UserModel = auth.get_user_model()

View File

@@ -31,6 +31,8 @@ class AuthorizationServerClient:
timeout,
proxy,
):
"""Require at a minimum url, url_jwks and url_introspection."""
if not url or not url_jwks or not url_introspection:
raise ImproperlyConfigured(
"Could not instantiate AuthorizationServerClient, some parameters are missing."

View File

@@ -0,0 +1 @@
"""Core template tags module."""

View File

@@ -0,0 +1 @@
"""Core tests."""

View File

@@ -0,0 +1 @@
"""Core authentication tests."""

View File

@@ -0,0 +1 @@
"""Core resource server tests."""

View File

@@ -0,0 +1 @@
"""Core Swagger tests."""

View File

@@ -0,0 +1 @@
"""Core utils module."""