From 332f7e2332757e7aa3aa8fec50583679be1a8608 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 29 Dec 2020 17:52:08 +0200 Subject: [PATCH] Fix Python 3.7 compatibility Both cached_property and Literal were introduced in Python 3.8 so they can't be used. --- etebase_fastapi/routers/authentication.py | 5 +++-- etebase_fastapi/utils.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/etebase_fastapi/routers/authentication.py b/etebase_fastapi/routers/authentication.py index 4b1b57a..efab7ef 100644 --- a/etebase_fastapi/routers/authentication.py +++ b/etebase_fastapi/routers/authentication.py @@ -1,6 +1,6 @@ import typing as t +from typing_extensions import Literal from datetime import datetime -from functools import cached_property import nacl import nacl.encoding @@ -12,6 +12,7 @@ from django.conf import settings from django.contrib.auth import user_logged_out, user_logged_in from django.core import exceptions as django_exceptions from django.db import transaction +from django.utils.functional import cached_property from fastapi import APIRouter, Depends, status, Request from django_etebase import app_settings, models @@ -43,7 +44,7 @@ class LoginResponse(BaseModel): username: str challenge: bytes host: str - action: t.Literal["login", "changePassword"] + action: Literal["login", "changePassword"] class UserOut(BaseModel): diff --git a/etebase_fastapi/utils.py b/etebase_fastapi/utils.py index 3a091c5..03f1a7d 100644 --- a/etebase_fastapi/utils.py +++ b/etebase_fastapi/utils.py @@ -1,5 +1,6 @@ import dataclasses import typing as t +from typing_extensions import Literal import msgpack import base64 @@ -17,7 +18,7 @@ from .exceptions import HttpError, HttpErrorOut User = get_typed_user_model() -Prefetch = t.Literal["auto", "medium"] +Prefetch = Literal["auto", "medium"] PrefetchQuery = Query(default="auto")