Applied the new type parameter syntax to the generic classes for Python 3.12.

This commit is contained in:
2024-03-03 07:39:37 +08:00
parent 1cf83adf87
commit 25d9904180
3 changed files with 10 additions and 21 deletions

View File

@ -1,7 +1,7 @@
# The Mia! Accounting Project.
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/18
# Copyright (c) 2023 imacat.
# Copyright (c) 2023-2024 imacat.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@
"""
import datetime as dt
from abc import ABC, abstractmethod
from typing import TypeVar, Generic, Type
from typing import Type
import sqlalchemy as sa
from flask_babel import LazyString
@ -308,11 +308,7 @@ class JournalEntryForm(FlaskForm):
return db.session.scalar(select)
T = TypeVar("T", bound=JournalEntryForm)
"""A journal entry form variant."""
class LineItemCollector(Generic[T], ABC):
class LineItemCollector[T: JournalEntryForm](ABC):
"""The line item collector."""
def __init__(self, form: T, obj: JournalEntry):