Skip to content

Commit

Permalink
fix: linting and type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kovaxis committed Jul 19, 2024
1 parent 13a2ecb commit ffbe2ea
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
10 changes: 3 additions & 7 deletions backend/app/plan/validation/courses/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ def _anihil_rule(
new.clear()
new.append(Const(value=not op.neutral))
anihilate[0] = True
if anihilate[0]:
return True
return False
return bool(anihilate[0])


def anihil(expr: Operator) -> Expr:
Expand All @@ -255,10 +253,8 @@ def anihil(expr: Operator) -> Expr:


def _ident_rule(ctx: None, op: Operator, new: list[Expr], child: Expr) -> bool:
if isinstance(child, Const) and child.value == op.neutral:
# Skip this child, since it adds nothing to the expression
return True
return False
# Skip this child, since it adds nothing to the expression
return isinstance(child, Const) and child.value == op.neutral


def ident(expr: Operator) -> Expr:
Expand Down
4 changes: 1 addition & 3 deletions backend/app/plan/validation/courses/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,4 @@ def is_course_indirectly_available(courseinfo: CourseInfo, code: str):
info = courseinfo.try_course(code)
if info is None:
return False
if courseinfo.is_available(info.canonical_equiv):
return True
return False
return courseinfo.is_available(info.canonical_equiv)
2 changes: 1 addition & 1 deletion backend/app/sync/curriculums/scrape/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(
if bloque.CodSigla is not None:
equivalents: list[str] = [bloque.CodSigla]
if bloque.Equivalencias is not None:
for equivalent in bloque.Equivalencias.Cursos:
for equivalent in bloque.Equivalencias.Cursos or []:
if equivalent.Sigla is not None:
equivalents.append(equivalent.Sigla)
if len(equivalents) > 1:
Expand Down
12 changes: 6 additions & 6 deletions backend/app/sync/curriculums/siding.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _filter_relevant_cyears(cyears: StringArray | None) -> bool:
if cyears is None:
return False
cyears.strings.string = [
cyear for cyear in cyears.strings.string if cyear >= IGNORE_CYEARS_BEFORE
cyear for cyear in cyears.strings.string or [] if cyear >= IGNORE_CYEARS_BEFORE
]
return len(cyears.strings.string) > 0

Expand All @@ -161,7 +161,7 @@ async def _fetch_siding_plans(siding: SidingInfo):
for major in siding.majors:
if major.Curriculum is None:
continue
for cyear_str in major.Curriculum.strings.string:
for cyear_str in major.Curriculum.strings.string or []:
cyear = cyear_from_str(cyear_str)
if cyear is None:
log.error(
Expand All @@ -184,7 +184,7 @@ async def _fetch_siding_plans(siding: SidingInfo):
for minor in siding.minors:
if minor.Curriculum is None:
continue
for cyear_str in minor.Curriculum.strings.string:
for cyear_str in minor.Curriculum.strings.string or []:
cyear = cyear_from_str(cyear_str)
if cyear is None:
log.error(
Expand All @@ -207,7 +207,7 @@ async def _fetch_siding_plans(siding: SidingInfo):
for title in siding.titles:
if title.Curriculum is None:
continue
for cyear_str in title.Curriculum.strings.string:
for cyear_str in title.Curriculum.strings.string or []:
cyear = cyear_from_str(cyear_str)
if cyear is None:
log.error(
Expand Down Expand Up @@ -278,7 +278,7 @@ def translate_siding(
codes = [main_code]
if raw_block.Equivalencias is not None:
# Add equivalences to the list
for curso in raw_block.Equivalencias.Cursos:
for curso in raw_block.Equivalencias.Cursos or []:
if curso.Sigla is not None and curso.Sigla != main_code:
codes.append(curso.Sigla)
list_code = (
Expand Down Expand Up @@ -385,7 +385,7 @@ def _fill_in_c2022_titles(courses: dict[str, CourseDetails], siding: SidingInfo)
if title.Curriculum is None:
continue
cyears = title.Curriculum.strings.string
if "C2020" in cyears and "C2022" not in cyears:
if cyears and "C2020" in cyears and "C2022" not in cyears:
cyears.append("C2022")
siding.plans["C2022"].plans[title.CodTitulo] = siding.plans["C2020"].plans[
title.CodTitulo
Expand Down
2 changes: 1 addition & 1 deletion backend/app/sync/siding/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _decode_curriculum_versions(input: StringArray | None) -> list[str]:
# too unreliable
logging.warning("null curriculum version list")
return []
return input.strings.string
return input.strings.string or []


def _decode_period(period: str) -> tuple[int, int]:
Expand Down

0 comments on commit ffbe2ea

Please sign in to comment.