Skip to content

Commit

Permalink
#13 More on types
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Jun 12, 2021
1 parent 3576509 commit 305cf8f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
21 changes: 19 additions & 2 deletions src/ska/contrib/django/ska/backends/constance_backend.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import json
from typing import Dict, Optional, Union

from constance import config

from django.conf import settings
from django.http import HttpRequest
from rest_framework.request import Request

from .base import BaseSkaAuthenticationBackend

Expand All @@ -15,7 +18,14 @@
class SkaAuthenticationConstanceBackend(BaseSkaAuthenticationBackend):
"""Authentication backend."""

def get_settings(self, request_data=None, request=None, **kwargs):
def get_settings(
self,
request_data: Optional[
Dict[str, Union[bytes, str, float, int]]
] = None,
request: Optional[Union[Request, HttpRequest]] = None,
**kwargs,
) -> Dict[str, Dict[str, str]]:
"""Get settings.
:return:
Expand All @@ -31,7 +41,14 @@ def get_settings(self, request_data=None, request=None, **kwargs):
pass
return config.SKA_PROVIDERS

def get_secret_key(self, request_data=None, request=None, **kwargs):
def get_secret_key(
self,
request_data: Optional[
Dict[str, Union[bytes, str, float, int]]
] = None,
request: Optional[Union[Request, HttpRequest]] = None,
**kwargs,
) -> str:
"""Get secret key.
:return:
Expand Down
22 changes: 20 additions & 2 deletions src/ska/contrib/django/ska/backends/default_backends.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from typing import Any, Dict, Optional, Union
from django.http import HttpRequest
from rest_framework.request import Request

from .base import BaseSkaAuthenticationBackend

__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
Expand All @@ -9,14 +13,28 @@
class SkaAuthenticationBackend(BaseSkaAuthenticationBackend):
"""Authentication backend."""

def get_settings(self, request_data=None, request=None, **kwargs):
def get_settings(
self,
request_data: Optional[
Dict[str, Union[bytes, str, float, int]]
] = None,
request: Optional[Union[Request, HttpRequest]] = None,
**kwargs,
) -> Dict[Any, Any]:
"""Get settings.
:return:
"""
return {}

def get_secret_key(self, request_data=None, request=None, **kwargs):
def get_secret_key(
self,
request_data: Optional[
Dict[str, Union[bytes, str, float, int]]
] = None,
request: Optional[Union[Request, HttpRequest]] = None,
**kwargs,
) -> None:
"""Get secret key.
:return:
Expand Down

0 comments on commit 305cf8f

Please sign in to comment.