Skip to content

fix: validate default rule path only when used - #937

Merged
haeter525 merged 2 commits into
ev-flow:masterfrom
binggao1230:fix-936-rule-default-validation
Jul 8, 2026
Merged

haeter525 merged 2 commits into
ev-flow:masterfrom
binggao1230:fix-936-rule-default-validation

Conversation

@binggao1230

Copy link
Copy Markdown
Contributor

Summary

  • stop Click from validating the default --rule path during option parsing
  • validate the rule path only when Quark actually loads rules from that path
  • add CLI regression tests for custom single-rule use and missing rule-directory use

Fixes #936.

Tests

  • uv run --with pytest --with requests --with click --with numpy --with tqdm --with prettytable --with colorama --with pathvalidate --with graphviz --with plotly --with-editable . pytest tests/test_cli.py -q
  • uv run --with black black --check tests/test_cli.py
  • git diff --check

Note: I did not run because the current file has pre-existing formatting that newer Black would reflow outside this fix. I kept the production diff to the rule option and the runtime path check.

@codecov

codecov Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.89%. Comparing base (1df1d49) to head (efa3c54).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
quark/cli.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #937   +/-   ##
=======================================
  Coverage   78.89%   78.89%           
=======================================
  Files          81       81           
  Lines        7131     7131           
=======================================
  Hits         5626     5626           
  Misses       1505     1505           
Flag Coverage Δ
unittests 78.89% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@binggao1230
binggao1230 force-pushed the fix-936-rule-default-validation branch 3 times, most recently from c8bd5b4 to e7c5349 Compare June 27, 2026 10:04

@haeter525 haeter525 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gaoflow, thank you for the fix!
I have a few comments below for minor simplifications. Once those are addressed, I think the PR is ready to merge.

Comment thread quark/cli.py Outdated
Comment thread tests/test_cli.py Outdated
@MickeyWzt

Copy link
Copy Markdown
Contributor

I checked this PR locally on Windows and found one small portability issue in the current test suite.

At 28b0ef7, running:

python -m pytest tests/test_cli.py -q

fails on Windows in test_missing_rules_path_fails_when_rules_are_loaded, because the error message uses {rule!r}. That escapes backslashes in Windows paths, so str(missing_rules) is not found in result.output.

Changing the message to use the plain path keeps the CLI output more readable and makes the assertion portable:

f"Path {rule} does not exist."

I also tried the two requested simplifications locally:

  • set exists=False directly on the --rule option
  • extract the duplicated Quark mock setup into a pytest fixture

With those changes plus the message tweak:

python -m pytest tests/test_cli.py -q
# 3 passed

uv run --with black black --check tests/test_cli.py
# passed

git diff --check
# passed

- Set exists=False directly on the --rule option instead of patching the
  parameter after the command is defined.
- Use the plain path in the missing-rule error so the assertion is portable
  on Windows (repr escapes backslashes).
- Extract the duplicated Quark mock into a mock_quark fixture.
@binggao1230

Copy link
Copy Markdown
Contributor Author

Thanks both. Addressed in efa3c54:

  • Set exists=False directly on the --rule option and dropped the post-hoc param patch (@haeter525).
  • Switched the error message to the plain path so the assertion is portable on Windows (@MickeyWzt).
  • Extracted the duplicated Quark mock into a mock_quark fixture (@haeter525).

pytest tests/test_cli.py is green here (3 passed).

@haeter525 haeter525 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @gaoflow for the fix!

@haeter525
haeter525 merged commit 8a480f8 into ev-flow:master Jul 8, 2026
17 of 18 checks passed
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.

--rule default path validated even when unused

3 participants