diff --git a/test/test_stageinfo.py b/test/test_stageinfo.py index 4e970c0d..8a9321ab 100644 --- a/test/test_stageinfo.py +++ b/test/test_stageinfo.py @@ -1,3 +1,4 @@ +import ast import json import unittest from pathlib import Path @@ -13,18 +14,17 @@ class TestStageInfo(unittest.TestCase): @staticmethod def get_stage_info(stage: Path) -> dict: '''Return the STAGE_* variables from the given stage.''' - # TODO: This works for now, but stages should probably have some + # NOTE: This works for now, but stages should probably have some # standard way of dumping this info so we (and other higher-level # tools) don't have to parse the code and walk through the AST # to find these values. - import ast stage_info = {} with open(stage) as fobj: stage_ast = ast.parse(fobj.read(), filename=stage) # STAGE_* assignments are at the toplevel, no need to walk() for node in stage_ast.body: - if type(node) is ast.Assign and type(node.value) == ast.Str: + if isinstance(node, ast.Assign) and isinstance(node.value, ast.Str): for target in node.targets: if target.id.startswith("STAGE_"): stage_info[target.id] = node.value.s @@ -55,7 +55,7 @@ class TestStageInfo(unittest.TestCase): stage_opts = self.parse_stage_opts(stage_info["STAGE_OPTS"]) self.assertIsNotNone(stage_opts) - # TODO: we probably want an actual JSON Schema validator but + # NOTE: We probably want an actual JSON Schema validator but # a nicely basic sanity test for our current STAGE_OPTS is: # 1. If it's not empty, there should be a "properties" object, # 2. If "required" exists, each item should be a property name