Skip to content

Commit

Permalink
Bugfix: pydantic migrate to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
vad-ii-k committed Aug 24, 2023
1 parent abd5865 commit 96083d5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tgbot/handlers/student_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def study_divisions_navigation_callback(
text=_("⬇️ Выберите уровень подготовки:"),
reply_markup=await create_study_levels_keyboard(study_levels),
)
await state.set_data({"study_levels": [level.dict() for level in study_levels]})
await state.set_data({"study_levels": [level.model_dump() for level in study_levels]})


@router.callback_query(StudyLevelCallbackFactory.filter())
Expand Down
2 changes: 1 addition & 1 deletion tgbot/services/initial_filling_of_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tgbot.services.schedule.data_classes import GroupSearchInfo, StudyLevel
from tgbot.services.timetable_api.timetable_api import TT_API_URL, get_study_divisions

program_ids: list[str] = []
program_ids: list[int] = []
groups: list[GroupSearchInfo] = []
remaining_program_ids: list[str] = []

Expand Down
2 changes: 1 addition & 1 deletion tgbot/services/schedule/getting_shedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def get_schedule_from_tt_depending_on_user_type(
schedule_from_timetable = await get_group_schedule_from_tt(tt_id, from_date=str(monday), to_date=str(sunday))
else:
schedule_from_timetable = await get_educator_schedule_from_tt(tt_id, from_date=str(monday), to_date=str(sunday))
return schedule_from_timetable.copy(deep=True)
return schedule_from_timetable.model_copy(deep=True)


async def get_text_week_schedule(tt_id: int, user_type: UserType, week_counter: int) -> tuple[str, str]:
Expand Down
7 changes: 3 additions & 4 deletions tgbot/services/timetable_api/timetable_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Wrappers over the timetable API """
import json
from typing import Final

from cashews import cache
Expand Down Expand Up @@ -64,7 +63,7 @@ async def get_study_levels(alias: str) -> list[StudyLevel]:


@cache(ttl="1d")
async def get_groups(program_id: str) -> list[GroupSearchInfo]:
async def get_groups(program_id: int) -> list[GroupSearchInfo]:
"""
:param program_id:
Expand Down Expand Up @@ -95,7 +94,7 @@ async def get_educator_schedule_from_tt(tt_id: int, from_date: str, to_date: str
"from_date": from_date,
"to_date": to_date,
}
educator_schedule = EducatorSchedule.parse_raw(json.dumps(response | support_info))
educator_schedule = EducatorSchedule.model_validate(response | support_info)
return educator_schedule


Expand All @@ -115,5 +114,5 @@ async def get_group_schedule_from_tt(tt_id: int, from_date: str, to_date: str) -
"from_date": from_date,
"to_date": to_date,
}
group_schedule = GroupSchedule.parse_raw(json.dumps(response | support_info))
group_schedule = GroupSchedule.model_validate(response | support_info)
return group_schedule

0 comments on commit 96083d5

Please sign in to comment.