diff --git a/backend/app/plan/validation/courses/simplify.py b/backend/app/plan/validation/courses/simplify.py index 20dceefd..af792d0f 100644 --- a/backend/app/plan/validation/courses/simplify.py +++ b/backend/app/plan/validation/courses/simplify.py @@ -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: @@ -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: diff --git a/backend/app/plan/validation/courses/validate.py b/backend/app/plan/validation/courses/validate.py index 4b44510b..550b2f34 100644 --- a/backend/app/plan/validation/courses/validate.py +++ b/backend/app/plan/validation/courses/validate.py @@ -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) diff --git a/backend/app/sync/curriculums/scrape/translate.py b/backend/app/sync/curriculums/scrape/translate.py index 615c0477..5290b87b 100644 --- a/backend/app/sync/curriculums/scrape/translate.py +++ b/backend/app/sync/curriculums/scrape/translate.py @@ -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: diff --git a/backend/app/sync/curriculums/siding.py b/backend/app/sync/curriculums/siding.py index df1ef005..55a7c205 100644 --- a/backend/app/sync/curriculums/siding.py +++ b/backend/app/sync/curriculums/siding.py @@ -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 @@ -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( @@ -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( @@ -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( @@ -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 = ( @@ -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 diff --git a/backend/app/sync/siding/translate.py b/backend/app/sync/siding/translate.py index 5a838dfd..6d2e55d3 100644 --- a/backend/app/sync/siding/translate.py +++ b/backend/app/sync/siding/translate.py @@ -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]: