Skip to content

Commit 127f5be

Browse files
adamtheturtleclaude
andcommitted
refactor: replace isinstance narrowing with two except clauses in vumark
Catching (UnknownTargetError, TargetStatusNotSuccessError) in a dedicated except clause means both types are already known to have target_id, so no pylint no-member suppressions are needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a643c21 commit 127f5be

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/vws_cli/vumark.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,16 @@ def _handle_vumark_exceptions() -> Iterator[None]:
5858

5959
try:
6060
yield
61-
except (
62-
VWSError,
63-
ServerError,
64-
) as exc:
61+
except (UnknownTargetError, TargetStatusNotSuccessError) as exc:
6562
if isinstance(exc, UnknownTargetError):
66-
error_message = f'Error: Target "{exc.target_id}" does not exist.' # pylint: disable=no-member
67-
elif isinstance(exc, TargetStatusNotSuccessError): # pragma: no cover
63+
error_message = f'Error: Target "{exc.target_id}" does not exist.'
64+
else: # pragma: no cover
6865
error_message = (
69-
f'Error: The target "{exc.target_id}" is not in the success ' # pylint: disable=no-member
66+
f'Error: The target "{exc.target_id}" is not in the success '
7067
"state and cannot be used to generate a VuMark instance."
7168
)
72-
elif isinstance(exc, InvalidInstanceIdError):
69+
except (VWSError, ServerError) as exc:
70+
if isinstance(exc, InvalidInstanceIdError):
7371
error_message = "Error: The given instance ID is invalid."
7472
elif isinstance(exc, InvalidTargetTypeError): # pragma: no cover
7573
error_message = (

0 commit comments

Comments
 (0)