Replaced importing the "typing" module as "t" with importing the individual names in the "typing" module. Since Python 3.9 introduced type hinting generics in standard collections, we do not have as many names to import now. This is also to be consistent with the practices of most major and standard packages and examples.

This commit is contained in:
2023-04-26 18:22:45 +08:00
parent ee5b447c23
commit cda9e4e3c6
25 changed files with 116 additions and 113 deletions

View File

@ -19,17 +19,17 @@
This module should not import any other module from the application.
"""
import typing as t
from abc import ABC, abstractmethod
from typing import TypeVar, Generic, Type
import sqlalchemy as sa
from flask import g, Response
from flask_sqlalchemy.model import Model
T = t.TypeVar("T", bound=Model)
T = TypeVar("T", bound=Model)
class UserUtilityInterface(t.Generic[T], ABC):
class UserUtilityInterface(Generic[T], ABC):
"""The interface for the user utilities."""
@abstractmethod
@ -72,7 +72,7 @@ class UserUtilityInterface(t.Generic[T], ABC):
@property
@abstractmethod
def cls(self) -> t.Type[T]:
def cls(self) -> Type[T]:
"""Returns the class of the user data model.
:return: The class of the user data model.
@ -112,7 +112,7 @@ class UserUtilityInterface(t.Generic[T], ABC):
__user_utils: UserUtilityInterface
"""The user utilities."""
user_cls: t.Type[Model] = Model
user_cls: Type[Model] = Model
"""The user class."""
user_pk_column: sa.Column = sa.Column(sa.Integer)
"""The primary key column of the user class."""