Skip to content

Commit

Permalink
Again changed type hints..
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliypopel committed Oct 11, 2024
1 parent d87a3b6 commit fccb781
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/django_routify/_abstraction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Type, Union
from typing import Any, Dict, List, Optional, Type

from django.urls import URLPattern

Expand Down Expand Up @@ -116,7 +116,7 @@ class BaseRouter(ABC):
Attributes:
ALLOWED_METHODS: str := ALLOWED_METHODS is a valid HTTP methods
__app_name: Union[str, None] := Application name same as app_name in urls.py
__app_name: Optional[str] := Application name same as app_name in urls.py
__prefix: str := Prefix for each url paths
__urls: List[URLPattern] := List of URLPatterns that can be included in urlpatterns
__auto_naming: bool = True := Auto naming for every view
Expand All @@ -127,7 +127,7 @@ class BaseRouter(ABC):
ALLOWED_METHODS = ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')
'ALLOWED_METHODS is a valid HTTP methods'

__app_name: Union[str, None]
__app_name: Optional[str]
'Application name same as app_name in urls.py'
__prefix: str
'Prefix for each url paths | By default equals ""'
Expand All @@ -149,8 +149,8 @@ def __init__(
) -> None:
"""
Initial method for Router.
:param prefix: Union[str, None]
:param app_name: Union[str, None]
:param prefix: Optional[str]
:param app_name: Optional[str]
:param kwargs: Any
"""

Expand Down
8 changes: 4 additions & 4 deletions src/django_routify/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.views import View

from inspect import isclass
from typing import Callable, List, Type, Union
from typing import Callable, List, Optional, Type, Union
import re

from ._abstraction import BaseRouter
Expand All @@ -22,7 +22,7 @@ class Router(BaseRouter):
Attributes:
ALLOWED_METHODS: str := ALLOWED_METHODS is a valid HTTP methods
__app_name: Union[str, None] := Application name same as app_name in urls.py
__app_name: Optional[str] := Application name same as app_name in urls.py
__prefix: str := Prefix for each url paths
__urls: List[URLPattern] := List of URLPatterns that can be included in urlpatterns
__auto_naming: bool = True := Auto naming for every view
Expand All @@ -38,8 +38,8 @@ def register(view: Union[FUNC_BASED_VIEW, View]) -> Union[FUNC_BASED_VIEW, View]
if isclass(view) and issubclass(view, View):
class_based = True

name: Union[str, None] = kwargs.get('name', None)
methods: Union[List[str], None] = kwargs.get('methods', None)
name: Optional[str] = kwargs.get('name', None)
methods: Optional[List[str]] = kwargs.get('methods', None)

_validate_type('url_path', url_path, str)
_validate_type('name', name, (str, type(None)))
Expand Down
4 changes: 2 additions & 2 deletions src/django_routify/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
def _validate_type(
obj_name: str,
obj: object,
expected_type: Union[Type, Tuple[Any]],
expected_type: Union[Type, Tuple],
) -> None:
"""
Function validator for router class.
Do not use it without need in your code!
:param obj_name: str
:param obj: object
:param expected_type: Union[Type, Tuple[Any]]
:param expected_type: Union[Type, Tuple]
:return: None
"""

Expand Down

0 comments on commit fccb781

Please sign in to comment.