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:
@ -18,8 +18,8 @@
|
||||
|
||||
"""
|
||||
import os
|
||||
import typing as t
|
||||
from secrets import token_urlsafe
|
||||
from typing import Type
|
||||
|
||||
from click.testing import Result
|
||||
from flask import Flask, Blueprint, render_template, redirect, Response, \
|
||||
@ -94,7 +94,7 @@ def create_app(is_testing: bool = False) -> Flask:
|
||||
return redirect(append_next(url_for("auth.login-form")))
|
||||
|
||||
@property
|
||||
def cls(self) -> t.Type[auth.User]:
|
||||
def cls(self) -> Type[auth.User]:
|
||||
return auth.User
|
||||
|
||||
@property
|
||||
|
@ -17,7 +17,7 @@
|
||||
"""The authentication for the Mia! Accounting demonstration website.
|
||||
|
||||
"""
|
||||
import typing as t
|
||||
from collections.abc import Callable
|
||||
|
||||
from flask import Blueprint, render_template, Flask, redirect, url_for, \
|
||||
session, request, g, Response, abort
|
||||
@ -96,7 +96,7 @@ def current_user() -> User | None:
|
||||
return g.user
|
||||
|
||||
|
||||
def admin_required(view: t.Callable) -> t.Callable:
|
||||
def admin_required(view: Callable) -> Callable:
|
||||
"""The view decorator to require the user to be an administrator.
|
||||
|
||||
:param view: The view.
|
||||
|
@ -20,10 +20,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import typing as t
|
||||
from abc import ABC, abstractmethod
|
||||
from decimal import Decimal
|
||||
from secrets import randbelow
|
||||
from typing import Any
|
||||
|
||||
import sqlalchemy as sa
|
||||
from flask import Flask
|
||||
@ -193,8 +193,8 @@ class BaseTestData(ABC):
|
||||
.filter(User.username == username).first()
|
||||
assert current_user is not None
|
||||
self.__current_user_id: int = current_user.id
|
||||
self.__journal_entries: list[dict[str, t.Any]] = []
|
||||
self.__line_items: list[dict[str, t.Any]] = []
|
||||
self.__journal_entries: list[dict[str, Any]] = []
|
||||
self.__line_items: list[dict[str, Any]] = []
|
||||
self._init_data()
|
||||
|
||||
@abstractmethod
|
||||
@ -258,7 +258,7 @@ class BaseTestData(ABC):
|
||||
assert account is not None
|
||||
debit_no = debit_no + 1
|
||||
line_item.id = self.__new_id(existing_l_id)
|
||||
data: dict[str, t.Any] \
|
||||
data: dict[str, Any] \
|
||||
= {"id": line_item.id,
|
||||
"journal_entry_id": journal_entry_data.id,
|
||||
"is_debit": True,
|
||||
@ -277,7 +277,7 @@ class BaseTestData(ABC):
|
||||
assert account is not None
|
||||
credit_no = credit_no + 1
|
||||
line_item.id = self.__new_id(existing_l_id)
|
||||
data: dict[str, t.Any] \
|
||||
data: dict[str, Any] \
|
||||
= {"id": line_item.id,
|
||||
"journal_entry_id": journal_entry_data.id,
|
||||
"is_debit": False,
|
||||
|
Reference in New Issue
Block a user