From 38b44e124644a4c2b7d943c1ebf74ed10ff7373f Mon Sep 17 00:00:00 2001 From: disinvite Date: Mon, 11 Dec 2023 22:40:38 -0500 Subject: [PATCH] Rename github action, better argparse for linter --- .github/workflows/order.yml | 4 ++-- tools/decomplint/decomplint.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/order.yml b/.github/workflows/order.yml index 0e0dda82..be766ad2 100644 --- a/.github/workflows/order.yml +++ b/.github/workflows/order.yml @@ -1,9 +1,9 @@ -name: Check order +name: Decomp marker linting on: [push, pull_request] jobs: - checkorder: + decomplint: runs-on: ubuntu-latest steps: diff --git a/tools/decomplint/decomplint.py b/tools/decomplint/decomplint.py index 2263ebbe..83d65a2b 100644 --- a/tools/decomplint/decomplint.py +++ b/tools/decomplint/decomplint.py @@ -33,7 +33,7 @@ def display_errors(alerts, filename): print(f"{colorama.Fore.WHITE} {alert.line}") -def parse_args() -> dict: +def parse_args() -> argparse.Namespace: p = argparse.ArgumentParser( description="Syntax checking and linting for decomp annotation markers." ) @@ -57,8 +57,8 @@ def parse_args() -> dict: help="Fail if syntax warnings are found and enforce is enabled.", ) - args = p.parse_args() - return vars(args) + (args, _) = p.parse_known_args() + return args def process_files(files, module=None): @@ -85,19 +85,19 @@ def process_files(files, module=None): def main(): args = parse_args() - if os.path.isdir(args["target"]): - files_to_check = list(walk_source_dir(args["target"])) - elif os.path.isfile(args["target"]) and is_file_cpp(args["target"]): - files_to_check = [args["target"]] + if os.path.isdir(args.target): + files_to_check = list(walk_source_dir(args.target)) + elif os.path.isfile(args.target) and is_file_cpp(args.target): + files_to_check = [args.target] else: sys.exit("Invalid target") - (warning_count, error_count) = process_files(files_to_check, module=args["module"]) + (warning_count, error_count) = process_files(files_to_check, module=args.module) print(colorama.Style.RESET_ALL, end="") - would_fail = error_count > 0 or (warning_count > 0 and args["warnfail"]) - if args["enforce"] and would_fail: + would_fail = error_count > 0 or (warning_count > 0 and args.warnfail) + if args.enforce and would_fail: sys.exit(1)