diff --git a/server/dearmep/config.py b/server/dearmep/config.py index 2d8509c6..7afc64ef 100644 --- a/server/dearmep/config.py +++ b/server/dearmep/config.py @@ -293,7 +293,7 @@ def intervals_by_weekday( If a weekday has no office hours, it will not be in the return value. """ return { - cast(WeekdayNumber, daynum): [ + cast("WeekdayNumber", daynum): [ OfficeHoursInterval(begin=self.begin, end=self.end), ] for daynum in range(1, 8) diff --git a/server/dearmep/convert/parltrack/mep.py b/server/dearmep/convert/parltrack/mep.py index b8ee9061..bfb97fff 100644 --- a/server/dearmep/convert/parltrack/mep.py +++ b/server/dearmep/convert/parltrack/mep.py @@ -122,13 +122,13 @@ def convert_person(raw_mep: Dict[str, Any]) -> Iterable[DumpableModels]: # Get the current group & constituency. group = next(( group - for group in cast(List[Dict[str, str]], raw_mep.get("Groups", [])) + for group in cast("List[Dict[str, str]]", raw_mep.get("Groups", [])) if is_current(group) ), None) constituency = next(( constituency for constituency in cast( - List[Dict[str, str]], raw_mep.get("Constituencies", [])) + "List[Dict[str, str]]", raw_mep.get("Constituencies", [])) if is_current(constituency) ), None) diff --git a/server/dearmep/convert/xml.py b/server/dearmep/convert/xml.py index 8cbffba4..6e27befc 100644 --- a/server/dearmep/convert/xml.py +++ b/server/dearmep/convert/xml.py @@ -10,7 +10,7 @@ def get_text(node: Union[Element, Text]) -> str: """Recursively concatenate text nodes in the `node`.""" if node.nodeType == node.TEXT_NODE: # This casting is plain ugly, but otherwise mypy doesn't know it's str. - return str(cast(Text, node).data) + return str(cast("Text", node).data) return "".join( get_text(child) for child in node.childNodes diff --git a/server/dearmep/database/query.py b/server/dearmep/database/query.py index fe6913c0..1be85810 100644 --- a/server/dearmep/database/query.py +++ b/server/dearmep/database/query.py @@ -71,7 +71,7 @@ def escape_for_like(value: str) -> str: def get_available_countries(session: Session) -> List[str]: countries = session.exec(select(Destination.country).distinct()).all() - return cast(List[str], countries) \ + return cast("List[str]", countries) \ if isinstance(countries, List) and len(countries) \ and isinstance(countries[0], str) \ else [] @@ -800,11 +800,11 @@ def get_currently_scheduled_calls( ScheduledCall.day == now.isoweekday(), and_( col(ScheduledCall.postponed_to).is_not(None), - cast(datetime, ScheduledCall.postponed_to) <= now, + cast("datetime", ScheduledCall.postponed_to) <= now, ), or_( col(ScheduledCall.last_postpone_queued_at).is_(None), - cast(date, ScheduledCall.last_postpone_queued_at) < now.date(), + cast("date", ScheduledCall.last_postpone_queued_at) < now.date(), ), ).order_by(ScheduledCall.postponed_to)).all() @@ -817,7 +817,7 @@ def get_currently_scheduled_calls( ), or_( col(ScheduledCall.last_queued_at).is_(None), - cast(date, ScheduledCall.last_queued_at) < now.date(), + cast("date", ScheduledCall.last_queued_at) < now.date(), ), ).order_by(ScheduledCall.start_time)).all()