Repository navigation
fix(lint): avoid recursion failures in valid Python expressions - #760
Merged
Merged
Conversation
Use an explicit stack for control-flow depth so valid long binary and attribute expressions cannot exhaust Python recursion during advisory lint. Preserve existing control-flow node counting and continue later scripts. Signed-off-by: Afloat <ShuffleMonkey@163.com>
Afloat16
requested review from
chrisknvidia,
mosheabr,
rmalani-nv and
rng1995
as code owners
November 17, 2026 08:13
Resolve the Unreleased changelog insertion while preserving exactly this pull request's code, tests, and release note against current main. Signed-off-by: Afloat <ShuffleMonkey@163.com>
rng1995
approved these changes
Nov 17, 2026
rng1995
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for your contribution, @Afloat16. Reviewed c2653cde8ad1; no actionable defects found in the changed code.
Focused validation: 29 script-lint tests passed.
Hosted CI is still awaiting authorization or completion; this is a code-review approval, and does not certify a full hosted CI pass.
This was referenced Nov 17, 2026
8 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A valid Python script can have a deep expression tree without deeply nested control flow. The nesting check recursively visits every AST node, so a roughly 12 KB function with a 1,500-term addition raises
RecursionErrorafter parsing succeeds. A long attribute chain has the same effect. This aborts advisory lint before findings for that script or later files can be reported.Walk the AST with an explicit stack carrying each node's control-flow depth. The recognized control-flow nodes, maximum-depth rule and advisory verdict remain unchanged. This addresses traversal of successfully parsed Python; it does not change parser-error handling.
Related changes in #677 added UTF-8 BOM support. This PR is based on main
cbda65c1, including that change, and fixes the independent traversal failure.Verification
Nine new cases: five fail and four compatibility controls pass against unchanged production. Real script files cover additions and attribute chains in both
scripts/andtools/, retained magic-number findings, continued checks on a second file and no false deep-nesting warning. Controls preserve flat, sibling, try/except and asynchronous depth semantics; a deep expression inside seven actual control-flow levels still measures seven.python -m pytest tests/validators/test_script_lint.py -q— 29 passed oncbda65c1plus this change, including the merged BOM regressions.python -m ruff check src tests— passed.Changed-file formatting and
git diff --check— passed.python -m build— wheel and sdist passed on the updated base.I am familiar with the Contributing Guidelines
Added or updated focused tests
Updated documentation for user-visible changes (Unreleased changelog)
Ran
make lintequivalent:python -m ruff check src testsFull
make testdid not complete successfully in this environment (see below)Ran
make buildequivalent:python -m buildDid not add credentials, private datasets, or proprietary benchmark content
The earlier full-suite attempt stops on unchanged base
d2cb138intest_gitlab_enriched_tier1_applies_the_keyless_job_baselines: its shell fixture hard-codesmktemp -d /tmp/..., while this workspace has no/tmp. That base run reached 456 passed, 2 skipped and 19 deselected before the failure.Release Impact
CHANGELOG.md