Skip to content

Commit

Permalink
Use ArgumentTypeError to raise error with message (#204)
Browse files Browse the repository at this point in the history
* fix: use ArgumentTypeError to raise error with message

Ref: #202

This PR is resolved with conflicts of #202.
So please close it after this pr is merged.
  • Loading branch information
eggplants committed Mar 11, 2022
1 parent d0d677f commit db695a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions SPARQLWrapper/main.py
Expand Up @@ -28,8 +28,7 @@ def check_file(v: str) -> str:
elif v == "-":
return "-" # stdin
else:
# type error: Argument 1 to "ArgumentError" has incompatible type "str"; expected "Optional[Action]"
raise argparse.ArgumentError("file '%s' is not found" % v) # type: ignore[arg-type, call-arg]
raise argparse.ArgumentTypeError("file '%s' is not found" % v)


def choicesDescriptions() -> str:
Expand Down
2 changes: 1 addition & 1 deletion test/test_cli.py
Expand Up @@ -88,7 +88,7 @@ def testInvalidFile(self):
self.assertEqual(cm.exception.code, 2)
self.assertEqual(
sys.stderr.getvalue().split("\n")[1],
"rqw: error: argument -f/--file: invalid check_file value: '440044.rq'",
"rqw: error: argument -f/--file: file '440044.rq' is not found",
)


Expand Down

0 comments on commit db695a5

Please sign in to comment.