Skip to content

Commit

Permalink
Don't leak an open file handle; fix Pyling R1732 (#584)
Browse files Browse the repository at this point in the history
**The problem**
The code had a case of a manual file handler pitfall, where a resource stream is opened manually and never closed.

This pitfall was detected using Pyling, which triggered a message of code R1732 with the content "Consider using 'with' for resource-allocating operations"

**The solution**
Used a 'with' block to automatically close the open stream on the file just after it is no longer needed
  • Loading branch information
NaelsonDouglas committed Oct 28, 2021
1 parent f91d08f commit 2d82594
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ def ttfautohint(path: str) -> None:
# Step 1.5: Adding STAT tables in one go
print ("[Cascadia Variable fonts] Fixing STAT tables")
fontSTAT = [fontTools.ttLib.TTFont(f) for f in list(OUTPUT_TTF_DIR.glob("*.ttf"))]
config = yaml.load(open(INPUT_DIR/"stat.yaml"), Loader=yaml.SafeLoader)
with open(INPUT_DIR/"stat.yaml") as f:
config = yaml.load(f, Loader=yaml.SafeLoader)
gen_stat_tables_from_config(config, fontSTAT)

for font in fontSTAT:
Expand Down

0 comments on commit 2d82594

Please sign in to comment.