fix python 3.8 compat for edoxid calendar sync

apache/airflow:2.7.1 base image ships Python 3.8, which doesn't have
zoneinfo (3.9+) and can't evaluate `X | Y` / list[X] type hints at
runtime (3.10+). Add `from __future__ import annotations` everywhere
and swap zoneinfo -> pytz (already a dependency in this repo).
This commit is contained in:
Power BI Dev
2026-07-27 22:10:10 +07:00
parent 33f4666bad
commit e0a6efd204
6 changed files with 27 additions and 12 deletions
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
from dataclasses import dataclass from dataclasses import dataclass
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from datetime import date, datetime from datetime import date, datetime
import pymysql import pymysql
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import base64 import base64
from email.mime.text import MIMEText from email.mime.text import MIMEText
+14 -10
View File
@@ -1,6 +1,8 @@
from datetime import datetime, timedelta from __future__ import annotations
from zoneinfo import ZoneInfo
from datetime import datetime, timedelta
import pytz
from google.auth.transport.requests import Request from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build from googleapiclient.discovery import build
@@ -8,7 +10,7 @@ from googleapiclient.errors import HttpError
from scripts.edoxid_calendar_config import GoogleConfig from scripts.edoxid_calendar_config import GoogleConfig
JAKARTA_TZ = ZoneInfo("Asia/Jakarta") JAKARTA_TZ = pytz.timezone("Asia/Jakarta")
TYPE_LABELS = { TYPE_LABELS = {
1: "Seminar Proposal", 1: "Seminar Proposal",
@@ -34,7 +36,9 @@ def get_schedule_datetime(submission: dict) -> datetime:
schedule = submission["schedule"] schedule = submission["schedule"]
if isinstance(schedule, str): if isinstance(schedule, str):
schedule = datetime.fromisoformat(schedule) schedule = datetime.fromisoformat(schedule)
return schedule.replace(tzinfo=JAKARTA_TZ) if schedule.tzinfo is not None:
return schedule
return JAKARTA_TZ.localize(schedule)
def get_type_label(submission: dict) -> str: def get_type_label(submission: dict) -> str:
@@ -50,8 +54,8 @@ def format_indonesian_date(date: datetime) -> str:
def build_description(submission: dict) -> str: def build_description(submission: dict) -> str:
schedule = get_schedule_datetime(submission) schedule = get_schedule_datetime(submission)
type_label = get_type_label(submission) type_label = get_type_label(submission)
pembimbing = [v for v in submission["verificators"] if v["type"] == "Pembimbing"] pembimbing = [v["name"] for v in submission["verificators"] if v["type"] == "Pembimbing"]
penguji = [v for v in submission["verificators"] if v["type"] == "Penguji"] penguji = [v["name"] for v in submission["verificators"] if v["type"] == "Penguji"]
lines = [ lines = [
f"UNDANGAN {type_label.upper()} SECARA LURING", f"UNDANGAN {type_label.upper()} SECARA LURING",
@@ -69,10 +73,10 @@ def build_description(submission: dict) -> str:
"", "",
] ]
for i, v in enumerate(pembimbing, start=1): for i, name in enumerate(pembimbing, start=1):
lines.append(f"📕 Pembimbing {i} : {v['name']}") lines.append(f"📕 Pembimbing {i} : {name}")
for i, v in enumerate(penguji, start=1): for i, name in enumerate(penguji, start=1):
lines.append(f"📒 Penguji {i} : {v['name']}") lines.append(f"📒 Penguji {i} : {name}")
lines += [ lines += [
"", "",
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import hashlib import hashlib
import json import json
import sqlite3 import sqlite3
+5 -2
View File
@@ -1,6 +1,9 @@
from __future__ import annotations
import logging import logging
from datetime import datetime, timedelta from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
import pytz
from scripts.edoxid_calendar_config import ( from scripts.edoxid_calendar_config import (
get_db_config, get_db_config,
@@ -22,7 +25,7 @@ from scripts.edoxid_calendar_state_store import StateStore
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
JAKARTA_TZ = ZoneInfo("Asia/Jakarta") JAKARTA_TZ = pytz.timezone("Asia/Jakarta")
# Toleransi jendela waktu untuk cek reminder — harus >= interval polling DAG (5 menit) # Toleransi jendela waktu untuk cek reminder — harus >= interval polling DAG (5 menit)
# supaya tidak ada window yang "kelewat" di antara 2 run. # supaya tidak ada window yang "kelewat" di antara 2 run.