Skip to content

Commit f13195f

Browse files
committed
Fix the bug of processing arguments[validator] in parse_args
1 parent 756de12 commit f13195f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

jsonschema/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ def _namedAnyWithDefault(name):
191191

192192
def parse_args(args):
193193
arguments = vars(parser.parse_args(args=args or ["--help"]))
194-
if arguments["validator"] is None:
195-
arguments["validator"] = validator_for(arguments["schema"])
196194
if arguments["output"] != "plain" and arguments["error_format"]:
197195
raise parser.error(
198196
"--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):
229227
except _CannotLoadFile:
230228
return 1
231229

230+
if arguments["validator"] is None:
231+
arguments["validator"] = validator_for(schema)
232+
232233
try:
233234
arguments["validator"].check_schema(schema)
234235
except SchemaError as error:

0 commit comments

Comments
 (0)