Skip to content

check_no_game_data: -h/--help print the usage and an unknown option exits 2 (EGEN-NOGAMEDATA-ARGS) - #6396

Closed
Vonsek wants to merge 3 commits into
ProjectLeonida:mainfrom
Vonsek:deepseek/10-nogamedata-args
Closed

Vonsek wants to merge 3 commits into
ProjectLeonida:mainfrom
Vonsek:deepseek/10-nogamedata-args

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

scripts/check_no_game_data.py took every argument as a file path, so -h/--help were checked like one, skipped as not a file, and the guard exited 0 with no output at all. A misspelt option was skipped the same way: a typo in the command could make the no-game-data gate exit 0 while checking nothing, which is the one failure this guard exists to catch.

What changed:

  • -h and --help print the module docstring, whose head is the usage, and check nothing (exit 0).
  • Any other argument that starts with - is one line, unknown option <flag>, plus the usage on stderr, and exit 2 — the code the other tools here use for bad arguments.
  • A lone -- ends the options, so a path whose own name starts with - can still be checked: python3 -I scripts/check_no_game_data.py -- -weird.bin.

Three commits, one per behaviour: the help, the unknown option, the -- separator (with the wider option scan it needs), each with its own test.

Test

python -I tests/test_check_no_game_data.py

Before, on main (8497c70) with the three new tests added and nothing else:

FAIL: test_help_prints_the_docstring_and_checks_nothing (flag='-h'/'--help')
AssertionError: 'python3 -I scripts/check_no_game_data.py' not found in ''
FAIL: test_unknown_option_is_a_usage_error_instead_of_a_skipped_path (flag='--frobnicate')
AssertionError: 0 != 2
Ran 10 tests ... FAILED (failures=4)

After: Ran 11 tests in 7.2s ... OK (the -- test included).

The script still passes on the repository itself: python -I scripts/check_no_game_data.py → exit 0.

No GPU needed.

Notes

  • Only one tool and its test change. No doc file spells out this guard's command line beyond the docstring, so the usage stays where -h prints it instead of a new section.
  • --commits is deliberately not the unknown-option sample in the test: check_no_game_data: --commits also checks files a pull request adds and deletes again #6079 adds --commits to this same script, so a test that asserts it is unknown would break when that PR lands. The samples are --frobnicate and -x.
  • The -- separator and the scan over every option position came out of the same fix: rejecting options would otherwise take a path called -foo for a misspelt option, which worked before.

AI-assisted.

…ipped as paths

The guard takes every argument as a path, so -h and --help were checked like one, skipped as not a file, and it exited 0 with no output. They now print the module docstring, whose head is the usage, and check nothing.
…y skipped path

An unknown option was taken for a file name, skipped as not a file, and the guard exited 0 - the worst answer for a guard that is meant to fail on a hit. It now names the option and the usage on stderr and exits 2, the exit code the other tools use for bad arguments.
…th a dash

Rejecting options would otherwise take a path called -foo for a misspelt option. Every argument that starts with '-' is now the option that is named, -h/--help may come after paths, and the usage lists the separator.
@milas6669

Copy link
Copy Markdown

Tested head 99d1d5327 on Windows 11 (build 26200), Python 3.14 (python -I), clean worktree:

  • tests/test_check_no_game_data.py: 11/11 tests passed in 8.27s
  • Verified -h / --help prints module usage and docstring and exits 0
  • Verified unknown flag (e.g. --frobnicate) prints unknown option --frobnicate to stderr and cleanly exits 2
  • Verified positional paths starting with - can be passed after -- separator
  • Full repository scan (python -I scripts/check_no_game_data.py) exits 0 with zero matches

Clean CLI argument handling without breaking existing path checks or repository verification. Synthetic tests only, no game files. AI-assisted.

@kapitche

Copy link
Copy Markdown
Collaborator

Tested 99d1d53 merged with main 8bcf3eb on Linux/Python 3.12.16: pass

Merge was clean (scripts/check_no_game_data.py, tests/test_check_no_game_data.py).

  • python -I tests/test_check_no_game_data.py: Ran 11 tests, OK.
  • Negative control (scripts/check_no_game_data.py restored from upstream/main, tests from the PR): Ran 11 tests, FAILED (failures=4): -h and --help print nothing on main, and --frobnicate and -x are treated as skipped paths. PR version restored afterwards. (The -- test passes on both, because on main a path named -weird.bin is simply a path; it guards the new separator.)

Diff read: -- ends option parsing, -h/--help print the docstring and exit 0, and any other argument starting with - is a usage error (exit 2) instead of a path that is skipped and lets the guard exit 0. The only caller in the tree, .github/workflows/no-game-data.yml, runs it with no arguments, so the CI invocation is unaffected; no script or doc passes a path that starts with a dash.

@Grimkaaah

Copy link
Copy Markdown
Contributor

Tested 99d1d5327 on Linux (CPython 3.13), CPU-only, synthetic inputs, no game files:

  • Red on main: -h prints nothing / exit 0; --bogus exit 0 (treated as a missing path).
  • Green on this head: python -m pytest tests/test_check_no_game_data.py → 11 passed. -h prints the docstring; unknown option → exit 2; -- -weird.bin still checks.

Pass.

AI-assisted (Cursor / Composer).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit 99d1d532)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants