summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwillson-chen <willson.chenwx@gmail.com>2020-08-20 16:04:51 +0800
committerwillson-chen <willson.chenwx@gmail.com>2020-08-20 20:12:10 +0800
commitf13195f874a4ae5c2ddcf889ceea8f1e2e8fa84b (patch)
treea3ecf8ce3f038ecb20f87dac4f0860c3a6e36d4d
parent756de12c69de8416469041a943ce9861b8e88141 (diff)
downloadjsonschema-f13195f874a4ae5c2ddcf889ceea8f1e2e8fa84b.tar.gz
Fix the bug of processing arguments[validator] in parse_args
-rw-r--r--jsonschema/cli.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/jsonschema/cli.py b/jsonschema/cli.py
index 4c2bb4f..7131939 100644
--- a/jsonschema/cli.py
+++ b/jsonschema/cli.py
@@ -191,8 +191,6 @@ parser.add_argument(
def parse_args(args):
arguments = vars(parser.parse_args(args=args or ["--help"]))
- if arguments["validator"] is None:
- arguments["validator"] = validator_for(arguments["schema"])
if arguments["output"] != "plain" and arguments["error_format"]:
raise parser.error(
"--error-format can only be used with --output plain"
@@ -229,6 +227,9 @@ def run(arguments, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin):
except _CannotLoadFile:
return 1
+ if arguments["validator"] is None:
+ arguments["validator"] = validator_for(schema)
+
try:
arguments["validator"].check_schema(schema)
except SchemaError as error: