Implement task API with input validation; implement error handling; refactoring

This commit is contained in:
Lexi / Zoe 2022-09-23 20:38:34 +02:00
parent 19d264a03b
commit 50aff05614
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
24 changed files with 612 additions and 131 deletions

View file

@ -1,16 +1,11 @@
from abc import ABC, abstractmethod
from typing import Callable, Type, TYPE_CHECKING
from typing import TYPE_CHECKING
from flask import Blueprint
from flask.views import View
if TYPE_CHECKING:
from tofu_api.app import App
__all__ = [
'BaseBlueprint',
]
class BaseBlueprint(Blueprint, ABC):
"""
@ -62,11 +57,3 @@ class BaseBlueprint(Blueprint, ABC):
Register child blueprints and URL rules.
"""
raise NotImplementedError
@staticmethod
def create_view_func(view_cls: Type[View], *args, **kwargs) -> Callable:
"""
Helper function to create a view function from a `View` class using `view_cls.as_view()`.
All arguments are passed to the constructor of the view class.
"""
return view_cls.as_view(view_cls.__name__, *args, **kwargs)