From 641dfd7ba05ffd4ba2c82b91eb29a0f27710123e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 17 Mar 2022 23:00:49 +0000 Subject: [PATCH] pythonism --- api/kiwi_vpn_api/config.py | 3 +-- api/kiwi_vpn_api/routers/user.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/api/kiwi_vpn_api/config.py b/api/kiwi_vpn_api/config.py index a8a2232..c5fab27 100644 --- a/api/kiwi_vpn_api/config.py +++ b/api/kiwi_vpn_api/config.py @@ -3,7 +3,6 @@ from __future__ import annotations import json from enum import Enum from pathlib import Path -from typing import Optional from fastapi import Depends from jose.constants import ALGORITHMS @@ -37,7 +36,7 @@ class DBConfig(BaseModel): class JWTConfig(BaseModel): - secret: Optional[str] = None + secret: str | None = None hash_algorithm: str = ALGORITHMS.HS256 expiry_minutes: int = 30 diff --git a/api/kiwi_vpn_api/routers/user.py b/api/kiwi_vpn_api/routers/user.py index 9409fa4..eae9636 100644 --- a/api/kiwi_vpn_api/routers/user.py +++ b/api/kiwi_vpn_api/routers/user.py @@ -1,6 +1,5 @@ from __future__ import annotations -from typing import Optional from fastapi import APIRouter, Depends, HTTPException, status from jose import JWTError, jwt @@ -18,7 +17,7 @@ class User(BaseModel): capabilities: list[str] @classmethod - def from_db(cls, username: str) -> Optional[User]: + def from_db(cls, username: str) -> User | None: user = db_User.get_by_name(username) if not user: