8000 MAINT: address improper error handling and cleanup for `spin` (#26304) · melissawm/numpy@509985c · GitHub
[go: up one dir, main page]

Skip to content

Commit 509985c

Browse files
authored
MAINT: address improper error handling and cleanup for spin (numpy#26304)
I just came across that while trying to benchmark docs. It seem that when this was moved from subprocess.run to spin.util run the error handling was not updated. spin.util seem to always return a CompletedProcess and it has the stderr and return code. (tested locally by changing towncrier to `false`). While at it I removed unused import and reformatted a tiny bit the pyprojet.toml to only have 1 command per line for readability.
1 parent 9022b0e commit 509985c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

.spin/cmds.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import os
22
import shutil
3-
import sys
4-
import argparse
5-
import tempfile
63
import pathlib
74
import shutil
8-
import json
95
import pathlib
106
import importlib
117
import subprocess
@@ -621,16 +617,10 @@ def notes(ctx, version_override):
621617
)
622618
# towncrier build --version 2.1 --yes
623619
cmd = ["towncrier", "build", "--version", version, "--yes"]
624-
try:
625-
p = util.run(
626-
cmd=cmd,
627-
sys_exit=False,
628-
output=True,
629-
encoding="utf-8"
630-
)
631-
except subprocess.SubprocessError as e:
620+
p = util.run(cmd=cmd, sys_exit=False, output=True, encoding="utf-8")
621+
if p.returncode != 0:
632622
raise click.ClickException(
633-
f"`towncrier` failed returned {e.returncode} with error `{e.stderr}`"
623+
f"`towncrier` failed returned {p.returncode} with error `{p.stderr}`"
634624
)
635625

636626
output_path = project_config['tool.towncrier.filename'].format(version=version)

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ cli = 'vendored-meson/meson/meson.py'
201201
".spin/cmds.py:lint",
202202
]
203203
"Environments" = [
204-
"spin.cmds.meson.run", ".spin/cmds.py:ipython",
205-
".spin/cmds.py:python", "spin.cmds.meson.gdb",
204+
"spin.cmds.meson.run",
205+
".spin/cmds.py:ipython",
206+
".spin/cmds.py:python",
207+
"spin.cmds.meson.gdb",
206208
"spin.cmds.meson.lldb"
207209
]
208210
"Documentation" = [

0 commit comments

Comments
 (0)
0