10000 ZipFile.open should be a context manager · randyoswald/document-api-python@813e079 · GitHub
[go: up one dir, main page]

Skip to content

Commit 813e079

Browse files
committed
ZipFile.open should be a context manager
1 parent cbcda8f commit 813e079

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tableaudocumentapi/containerfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def find_file_in_zip(zip):
2929

3030
def get_xml_from_archive(filename):
3131
with zipfile.ZipFile(filename) as zf:
32-
xml_file = zf.open(find_file_in_zip(zf))
33-
xml_tree = ET.parse(xml_file)
32+
with zf.open(find_file_in_zip(zf)) as xml_file:
33+
xml_tree = ET.parse(xml_file)
3434

3535
return xml_tree
3636

0 commit comments

Comments
 (0)
0