minor fixes

This commit is contained in:
Alexander Kalinovsky
2025-02-08 00:04:56 +01:00
parent 7f61a2885d
commit 39664ae355
2 changed files with 16 additions and 7 deletions

View File

@@ -56,6 +56,12 @@ async def time_picker(
if not current_value: if not current_value:
current_value = time(0, 0) current_value = time(0, 0)
else:
remainder = current_value.minute % 5
if remainder >= 3:
current_value += timedelta(minutes=(5 - remainder))
else:
current_value -= timedelta(minutes=remainder)
for i in range(12): for i in range(12):
keyboard_builder.row( keyboard_builder.row(
@@ -173,7 +179,7 @@ async def date_picker(
else: else:
start_date = current_value start_date = current_value
start_date = current_value.replace(day=1) start_date = start_date.replace(day=1)
previous_month = start_date - timedelta(days=1) previous_month = start_date - timedelta(days=1)
next_month = start_date.replace(day=28) + timedelta(days=4) next_month = start_date.replace(day=28) + timedelta(days=4)

View File

@@ -86,13 +86,16 @@ class BotEntityMetaclass(SQLModelMetaclass):
field_descriptor.is_list = is_list = True field_descriptor.is_list = is_list = True
field_descriptor.type_base = type_ = get_args(type_)[0] field_descriptor.type_base = type_ = get_args(type_)[0]
if type_origin == Union and isinstance(get_args(type_)[0], ForwardRef): if type_origin is Union:
field_descriptor.is_optional = is_optional = True args = get_args(type_)
field_descriptor.type_base = type_ = get_args(type_)[ if isinstance(args[0], ForwardRef):
0 field_descriptor.is_optional = is_optional = True
].__forward_arg__ field_descriptor.type_base = type_ = args[0].__forward_arg__
elif args[1] is NoneType:
field_descriptor.is_optional = is_optional = True
field_descriptor.type_base = type_ = args[0]
if type_origin == UnionType and get_args(type_)[1] == NoneType: if type_origin is UnionType and get_args(type_)[1] is NoneType:
field_descriptor.is_optional = is_optional = True field_descriptor.is_optional = is_optional = True
field_descriptor.type_base = type_ = get_args(type_)[0] field_descriptor.type_base = type_ = get_args(type_)[0]