Replace typing.Type with built-in type[] for Python 3.12.

This commit is contained in:
2026-04-05 21:49:17 +08:00
parent cca3f89bf1
commit 356950e2c7
9 changed files with 19 additions and 26 deletions
@@ -19,7 +19,6 @@
"""
import datetime as dt
from abc import ABC, abstractmethod
from typing import Type
import sqlalchemy as sa
from flask_babel import LazyString
@@ -122,7 +121,7 @@ class JournalEntryForm(FlaskForm):
super().__init__(*args, **kwargs)
self.is_modified: bool = False
"""Whether the journal entry is modified during populate_obj()."""
self.collector: Type[LineItemCollector] = LineItemCollector
self.collector: type[LineItemCollector] = LineItemCollector
"""The line item collector. The default is the base abstract
collector only to provide the correct type. The subclass forms should
provide their own collectors."""
@@ -153,7 +152,7 @@ class JournalEntryForm(FlaskForm):
self.__set_date(obj, self.date.data)
obj.note = self.note.data
collector_cls: Type[LineItemCollector] = self.collector
collector_cls: type[LineItemCollector] = self.collector
collector: collector_cls = collector_cls(self, obj)
collector.collect()
@@ -18,7 +18,6 @@
"""
from abc import ABC, abstractmethod
from typing import Type
from flask import render_template, request, abort
from flask_wtf import FlaskForm
@@ -38,7 +37,7 @@ class JournalEntryOperator(ABC):
@property
@abstractmethod
def form(self) -> Type[JournalEntryForm]:
def form(self) -> type[JournalEntryForm]:
"""Returns the form class.
:return: The form class.
@@ -99,7 +98,7 @@ class CashReceiptJournalEntry(JournalEntryOperator):
"""The order when checking the journal entry operator."""
@property
def form(self) -> Type[JournalEntryForm]:
def form(self) -> type[JournalEntryForm]:
"""Returns the form class.
:return: The form class.
@@ -169,7 +168,7 @@ class CashDisbursementJournalEntry(JournalEntryOperator):
"""The order when checking the journal entry operator."""
@property
def form(self) -> Type[JournalEntryForm]:
def form(self) -> type[JournalEntryForm]:
"""Returns the form class.
:return: The form class.
@@ -242,7 +241,7 @@ class TransferJournalEntry(JournalEntryOperator):
"""The order when checking the journal entry operator."""
@property
def form(self) -> Type[JournalEntryForm]:
def form(self) -> type[JournalEntryForm]:
"""Returns the form class.
:return: The form class.