Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c818393

Browse filesBrowse files
committed
Switch to tempdirectory for windows support and autocleanup
1 parent d7ad3ad commit c818393
Copy full SHA for c818393

File tree

Expand file treeCollapse file tree

1 file changed

+12
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-12
lines changed

‎tools/stubtest.py

Copy file name to clipboardExpand all lines: tools/stubtest.py
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,25 @@ def visit_ClassDef(self, node):
5252
self.visit(child)
5353

5454

55-
with tempfile.NamedTemporaryFile("wt", delete=False) as f:
56-
for path in mpl.glob("**/*.py"):
57-
v = Visitor(path, f)
58-
tree = ast.parse(path.read_text())
55+
with tempfile.TemporaryDirectory() as d:
56+
p = pathlib.Path(d) / "allowlist.txt"
57+
with p.open("wt") as f:
58+
for path in mpl.glob("**/*.py"):
59+
v = Visitor(path, f)
60+
tree = ast.parse(path.read_text())
5961

60-
# Assign parents to tree so they can be backtraced
61-
for node in ast.walk(tree):
62-
for child in ast.iter_child_nodes(node):
63-
child.parent = node
62+
# Assign parents to tree so they can be backtraced
63+
for node in ast.walk(tree):
64+
for child in ast.iter_child_nodes(node):
65+
child.parent = node
6466

65-
v.visit(tree)
66-
f.flush()
67-
f.close()
67+
v.visit(tree)
6868
proc = subprocess.run(
6969
[
7070
"stubtest",
7171
"--mypy-config-file=pyproject.toml",
7272
"--allowlist=ci/mypy-stubtest-allowlist.txt",
73-
f"--allowlist={f.name}",
73+
f"--allowlist={str(p)}",
7474
"matplotlib",
7575
],
7676
cwd=root,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.