Skip to content

Commit 77f7019

Browse files
[PATCH] Apply suggestions from code review (- WIP PR #169 -)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 675a9ca commit 77f7019

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

multicast/exceptions.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,9 @@ def __init__(self, *args, **kwargs):
199199
>>> error.exit_code
200200
2
201201
"""
202-
if len(args) > 0 and isinstance(args[-1], int):
203-
exit_code = args[-1]
204-
args = args[:-1]
205-
else:
206-
exit_code = kwargs.pop("exit_code", 1)
207-
super().__init__(*args, **kwargs)
208-
self.message = args[0] if args else kwargs.get("message", "An error occurred")
202+
exit_code = kwargs.pop("exit_code", 1)
203+
message = args[0] if args else kwargs.get("message", "An error occurred")
204+
super().__init__(message)
209205
self.exit_code = exit_code
210206

211207

@@ -249,7 +245,7 @@ def wrapper(*args, **kwargs):
249245
except SystemExit as exc:
250246
# Handle SystemExit exceptions, possibly from argparse
251247
exit_code = exc.code if isinstance(exc.code, int) else 2
252-
if (sys.stdout.isatty()):
248+
if (sys.stderr.isatty()):
253249
print(
254250
f"{EXIT_CODES.get(exit_code, (1, 'General Error'))[1]}: {exc}",
255251
file=sys.stderr

tests/check_spelling

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ hash -p ./.github/tool_shlock_helper.sh shlock || exit 255 ;
128128
check_command shlock ;
129129

130130

131-
SCRIPT_FILE="test/check_spelling"
131+
SCRIPT_FILE="tests/check_spelling"
132132

133133
# Set codespell options
134134
CODESPELL_OPTIONS="--quiet-level=4 --builtin clear,rare,code -L assertIn"

0 commit comments

Comments
 (0)