diff --git a/tealish/build.py b/tealish/build.py index a28d429..f5e4c27 100644 --- a/tealish/build.py +++ b/tealish/build.py @@ -17,8 +17,10 @@ def assemble_with_goal(teal: str) -> Tuple[bytes, SourceMap]: raise Exception("goal not found in path") except subprocess.CalledProcessError as e: raise Exception(e.output) - bytecode = open(tmp_out_filename, "rb").read() - algod_sourcemap = json.load(open(tmp_out_filename + ".map")) + with open(tmp_out_filename, "rb") as f: + bytecode = f.read() + with open(tmp_out_filename + ".map", "r") as f: + algod_sourcemap = json.load(f) return bytecode, SourceMap(algod_sourcemap) diff --git a/tealish/cli.py b/tealish/cli.py index e5b9668..0ddb010 100644 --- a/tealish/cli.py +++ b/tealish/cli.py @@ -36,7 +36,8 @@ def _build( teal_filename = output_path / f"{base_filename}.teal" if not quiet: click.echo(f"Compiling {path} to {teal_filename}") - teal, tealish_map = _compile_program(open(path).read()) + with open(path, "r") as f: + teal, tealish_map = _compile_program(f.read()) teal_string = "\n".join(teal + [""]) with open(teal_filename, "w") as f: f.write("\n".join(teal + [""])) diff --git a/tealish/langspec.py b/tealish/langspec.py index fd15047..ce2b5ae 100644 --- a/tealish/langspec.py +++ b/tealish/langspec.py @@ -245,7 +245,8 @@ def get_field_type(self, namespace: str, name: str) -> str: local_lang_spec: Optional[LangSpec] = None if os.path.exists("langspec.json"): - local_lang_spec = LangSpec(json.load(open("langspec.json"))) + with open("langspec.json", "r") as f: + local_lang_spec = LangSpec(json.load(f)) def get_active_langspec() -> LangSpec: