mirror of
https://github.com/b4tman/sync_ics2gcal
synced 2026-06-03 18:36:12 +03:00
fix mypy issues
This commit is contained in:
@@ -57,6 +57,9 @@ manage-ics2gcal = "sync_ics2gcal.manage_calendars:main"
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.mypy]
|
||||
disable_error_code = "unused-ignore"
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = [
|
||||
'icalendar',
|
||||
|
||||
@@ -120,7 +120,7 @@ class GoogleCalendarService:
|
||||
scopes = ["https://www.googleapis.com/auth/calendar"]
|
||||
credentials = service_account.Credentials.from_service_account_file(
|
||||
service_account_file
|
||||
)
|
||||
) # type: ignore[no-untyped-call]
|
||||
scoped_credentials = credentials.with_scopes(scopes)
|
||||
service = discovery.build(
|
||||
"calendar", "v3", credentials=scoped_credentials, cache_discovery=False
|
||||
|
||||
@@ -182,12 +182,12 @@ class CalendarConverter:
|
||||
def load(self, filename: str) -> None:
|
||||
"""load calendar from ics file"""
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
self.calendar = Calendar.from_ical(f.read())
|
||||
self.calendar = cast(Calendar, Calendar.from_ical(f.read())) # type: ignore[redundant-cast]
|
||||
self.logger.info("%s loaded", filename)
|
||||
|
||||
def loads(self, string: str) -> None:
|
||||
"""load calendar from ics string"""
|
||||
self.calendar = Calendar.from_ical(string)
|
||||
self.calendar = cast(Calendar, Calendar.from_ical(string)) # type: ignore[redundant-cast]
|
||||
|
||||
def events_to_gcal(self) -> EventList:
|
||||
"""Convert events to google calendar resources"""
|
||||
@@ -195,10 +195,10 @@ class CalendarConverter:
|
||||
if self.calendar is None:
|
||||
raise ValueError("calendar not set")
|
||||
|
||||
calendar: Calendar = cast(Calendar, self.calendar)
|
||||
calendar: Calendar = cast(Calendar, self.calendar) # type: ignore[redundant-cast]
|
||||
ics_events = calendar.walk(name="VEVENT")
|
||||
self.logger.info("%d events read", len(ics_events))
|
||||
|
||||
result = list(map(lambda event: EventConverter(event).convert(), ics_events))
|
||||
result = list(map(lambda event: EventConverter(event).convert(), ics_events)) # type: ignore[no-untyped-call]
|
||||
self.logger.info("%d events converted", len(result))
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user