Skip to content

Lint rezconfig.py for common mistakes - #2176

Draft
JeanChristopheMorinPerso wants to merge 5 commits into
AcademySoftwareFoundation:mainfrom
JeanChristopheMorinPerso:feature/rezconfig-versionadded
Draft

Lint rezconfig.py for common mistakes#2176
JeanChristopheMorinPerso wants to merge 5 commits into
AcademySoftwareFoundation:mainfrom
JeanChristopheMorinPerso:feature/rezconfig-versionadded

Conversation

@JeanChristopheMorinPerso

@JeanChristopheMorinPerso JeanChristopheMorinPerso commented Aug 1, 2026

Copy link
Copy Markdown
Member

A common mistake make by most people (including me) when editing the rezconfig.py is is to either forget to add documentation or to add a .. versionadded sphinx directive.

This PR adds a custom linter that can detect both of the problems. It can also detect if a setting is added outside a section.

To achieve that, I refactored the code to extract the docs that was in the sphinx extension into its own module.

The linting happens inside the tests. That's the "cleanest" option I found that allows to catch these problems locally and in CI.

Note that this PR is mostly AI generated using Amp: https://ampcode.com/threads/T-019fbef7-632f-767e-ad1c-68582e67859f

Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019fbef7-632f-767e-ad1c-68582e67859f
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
@JeanChristopheMorinPerso
JeanChristopheMorinPerso requested a review from a team as a code owner August 1, 2026 22:59
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
@JeanChristopheMorinPerso
JeanChristopheMorinPerso marked this pull request as draft August 1, 2026 23:03
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
@JeanChristopheMorinPerso
JeanChristopheMorinPerso force-pushed the feature/rezconfig-versionadded branch from 433ef1e to 514db50 Compare August 1, 2026 23:06
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.38%. Comparing base (a4160c2) to head (d1244c0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/rez/utils/docs.py 95.16% 1 Missing and 2 partials ⚠️
src/rez/cli/selftest.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2176      +/-   ##
==========================================
+ Coverage   61.29%   61.38%   +0.09%     
==========================================
  Files         164      165       +1     
  Lines       20568    20633      +65     
  Branches     3575     3594      +19     
==========================================
+ Hits        12607    12666      +59     
- Misses       7089     7094       +5     
- Partials      872      873       +1     

☔ 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a reusable parser for “documented settings” inside rezconfig.py and uses it in unit tests to lint for common rezconfig documentation mistakes (missing section placement, missing docs, missing .. versionadded:: for new settings). It also updates the Sphinx extension to reuse the same parsing logic and adjusts CI/selftest so the “new settings” check can compare against the appropriate Git baseline.

Changes:

  • Added rez.utils.docs.parse_documented_settings() to extract documented rezconfig settings (names, values, comment blocks, and section metadata).
  • Added selftests that enforce rezconfig documentation conventions, including a Git-aware “new settings must include .. versionadded::” rule.
  • Updated the Sphinx extension and CI workflow to rely on the shared parsing code and provide sufficient Git history/baseline information.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/rez/utils/docs.py New shared parser for documented rezconfig settings used by both docs generation and tests.
src/rez/tests/test_utils_docs.py Unit tests validating the documented-settings parser and the “versionadded must be in the immediately preceding comment block” behavior.
src/rez/tests/test_rezconfig.py New lint-style tests enforcing rezconfig documentation/section rules and Git-baseline comparison for new settings.
src/rez/cli/selftest.py Adds --rezconfig-baseline option to pass a baseline revision into selftests via env var.
docs/rez_sphinxext.py Refactors rezconfig-to-RST generation to use the new shared parser.
.github/workflows/tests.yaml Ensures full Git history is available and passes an appropriate baseline SHA to rez-selftest in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +98 to +103
"""Validate that the rezconfig file follow the project's conventions.

The goal is to catch common mistakes when modifying the rezconfig file.
That file is use as the default settings but it's also used to generate
the settings documentation and it must follow some rules.
"""
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.

2 participants