From f13195f874a4ae5c2ddcf889ceea8f1e2e8fa84b Mon Sep 17 00:00:00 2001 From: willson-chen Date: Thu, 20 Aug 2020 16:04:51 +0800 Subject: Fix the bug of processing arguments[validator] in parse_args --- jsonschema/cli.py | 5 +++-- 1 file 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: -- cgit v1.2.1