mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-27 20:09:57 +00:00
strict typing, change colors a bit, architecture depending lock
This commit is contained in:
@ -17,15 +17,19 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp.web import middleware, Request, Response
|
||||
from aiohttp.web import middleware, Request
|
||||
from aiohttp.web_exceptions import HTTPClientError
|
||||
from aiohttp.web_response import StreamResponse
|
||||
from logging import Logger
|
||||
from typing import Callable
|
||||
from typing import Awaitable, Callable
|
||||
|
||||
|
||||
def exception_handler(logger: Logger) -> Callable:
|
||||
HandlerType = Callable[[Request], Awaitable[StreamResponse]]
|
||||
|
||||
|
||||
def exception_handler(logger: Logger) -> Callable[[Request, HandlerType], Awaitable[StreamResponse]]:
|
||||
@middleware
|
||||
async def handle(request: Request, handler: Callable) -> Response:
|
||||
async def handle(request: Request, handler: HandlerType) -> StreamResponse:
|
||||
try:
|
||||
return await handler(request)
|
||||
except HTTPClientError:
|
||||
|
@ -27,4 +27,5 @@ class BaseView(View):
|
||||
|
||||
@property
|
||||
def service(self) -> Watcher:
|
||||
return self.request.app['watcher']
|
||||
watcher: Watcher = self.request.app['watcher']
|
||||
return watcher
|
||||
|
@ -17,7 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp_jinja2 import template
|
||||
import aiohttp_jinja2 # type: ignore
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
import ahriman.version as version
|
||||
@ -27,7 +28,7 @@ from ahriman.web.views.base import BaseView
|
||||
|
||||
class IndexView(BaseView):
|
||||
|
||||
@template("build-status.jinja2")
|
||||
@aiohttp_jinja2.template("build-status.jinja2") # type: ignore
|
||||
async def get(self) -> Dict[str, Any]:
|
||||
# some magic to make it jinja-friendly
|
||||
packages = [
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import aiohttp_jinja2
|
||||
import aiohttp_jinja2 # type: ignore
|
||||
import jinja2
|
||||
import logging
|
||||
|
||||
|
Reference in New Issue
Block a user