Repository navigation
ci: ratchet FL_NOEXCEPT lint coverage - #2987
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (43)
📝 WalkthroughWalkthroughThis PR introduces an AST-backed FL_NOEXCEPT checker with baseline-aware reporting (ci/tools/check_noexcept.py + tests + TUs), wires it into the unified C++ lint runner (ci/lint_cpp/run_all_checkers.py and ci/lint/*), and applies FL_NOEXCEPT annotations across many FastLED and vendored source headers/implementations. ChangesFL_NOEXCEPT AST Enforcement and Integration
Sequence Diagram(s)sequenceDiagram
participant Developer as Developer runs<br/>bash lint --cpp
participant RunAll as run_all_checkers.py
participant AstCheck as run_noexcept_ast_check
participant CheckTool as check_noexcept.py
participant Baseline as baseline file
Developer->>RunAll: invoke (single-file or all-files)
RunAll->>AstCheck: call run_noexcept_ast_check(file_path)
AstCheck->>CheckTool: find_missing_noexcept(scope)
CheckTool->>CheckTool: run clang-query<br/>on TU
CheckTool->>CheckTool: parse matches<br/>normalize signatures<br/>filter exemptions
CheckTool-->>AstCheck: list[NoexceptHit]
AstCheck->>Baseline: load_baseline()
Baseline-->>AstCheck: Counter[path|signature]
AstCheck->>AstCheck: diff_against_baseline()
AstCheck-->>RunAll: CheckerResults<br/>(new violations)
RunAll->>RunAll: add NoexceptAstChecker<br/>to aggregated results
RunAll-->>Developer: report violations
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/lint_cpp/run_all_checkers.py`:
- Around line 574-575: The code always calls find_missing_noexcept("all") even
in the single-file fast-path; change the logic so when single-file mode is
active it calls find_missing_noexcept with that single filename (or scope)
instead of "all" to avoid a full-scope AST run. Update the try/except around the
call that catches NoexceptCheckError to use the same conditional: if running
single-file use the single file identifier passed into the checker, otherwise
keep "all". Ensure you reference the existing find_missing_noexcept and
NoexceptCheckError symbols and reuse the single-file mode variable/parameter
already used in the single-file branch.
In `@ci/tools/check_noexcept.py`:
- Around line 113-114: The function signatures in this file use default
parameter values which violates the repo rule; change load_baseline(path: Path =
DEFAULT_BASELINE) -> Counter[str] to remove the default (load_baseline(path:
Path) -> Counter[str]) and do the same for the other flagged signatures in this
file (the other two functions that currently have defaulted parameters); ensure
each parameter retains its explicit type annotation, update all call sites to
pass the required arguments (or hoist the DEFAULT_* constant usage into the
caller), and run linters/tests to confirm no signature-rule violations remain.
- Around line 27-28: The new dataclass NoexceptHit is missing the `@typechecked`
decorator required for runtime type validation; update the declaration of
NoexceptHit to add the `@typechecked` decorator above the `@dataclass` decorator
(importing typechecked from typeguard if not already imported) so the class uses
runtime type checking alongside dataclass behavior.
In `@ci/tools/test_check_noexcept.py`:
- Line 70: Replace the list-comprehension assertion in
ci/tools/test_check_noexcept.py that checks [hit.line for hit in new_hits] ==
[11, 12] with an explicit loop: create an explicit list or iterate over new_hits
using a for loop, collect or compare each hit.line against the expected sequence
(e.g., expected_lines = [11, 12]) and assert per-item equality (or build the
list with append and assert equality), referencing the variable new_hits and the
expected_lines array to improve clarity and debuggability.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c5751834-a0dd-44c3-880c-ae45c3fe03b4
📒 Files selected for processing (9)
ci/lint.pyci/lint/stage_impls.pyci/lint_cpp/run_all_checkers.pyci/tools/_noexcept_check_fl_tu.cppci/tools/check_noexcept.pyci/tools/noexcept_baseline.txtci/tools/test_check_noexcept.pysrc/fl/channels/data.cpp.hppsrc/platforms/stub/watchdog_stub.impl.hpp
| from dataclasses import dataclass | ||
| from pathlib import Path |
There was a problem hiding this comment.
Add runtime type validation to NoexceptHit.
Line 75 introduces a new dataclass without the required @typechecked decorator.
As per coding guidelines, "Use @typechecked decorator with @dataclass for runtime type validation."
Proposed fix
from collections import Counter
from dataclasses import dataclass
+from typeguard import typechecked
from pathlib import Path
@@
+@typechecked
`@dataclass`(frozen=True)
class NoexceptHit:Also applies to: 75-76
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ci/tools/check_noexcept.py` around lines 27 - 28, The new dataclass
NoexceptHit is missing the `@typechecked` decorator required for runtime type
validation; update the declaration of NoexceptHit to add the `@typechecked`
decorator above the `@dataclass` decorator (importing typechecked from typeguard
if not already imported) so the class uses runtime type checking alongside
dataclass behavior.
Source: Coding guidelines
There was a problem hiding this comment.
Declining: @typechecked is not a repository-wide requirement. agents/docs/python-standards.md does not mandate it, and the majority of existing @dataclass declarations in ci/ (e.g. ci/boards.py, ci/bloat.py, ci/run_tests.py, ci/lint_cpp/run_all_checkers.py) do not use it. Adding it here would be inconsistent with established style.
| def load_baseline(path: Path = DEFAULT_BASELINE) -> Counter[str]: | ||
| """Load the checked-in baseline as a counted set of signature keys.""" |
There was a problem hiding this comment.
Remove default values from changed function parameters.
Line 113, Line 126, and Line 289 define default parameter values, which violates the Python function-signature rule in this repository.
As per coding guidelines, "All function parameters MUST have explicit type annotations and MUST NOT have default values."
Proposed fix
-def load_baseline(path: Path = DEFAULT_BASELINE) -> Counter[str]:
+def load_baseline(path: Path) -> Counter[str]:
@@
-def write_baseline(hits: list[NoexceptHit], path: Path = DEFAULT_BASELINE) -> None:
+def write_baseline(hits: list[NoexceptHit], path: Path) -> None:
@@
-def find_missing_noexcept(scope: str = "all") -> list[NoexceptHit]:
+def find_missing_noexcept(scope: str) -> list[NoexceptHit]:Also applies to: 126-127, 289-290
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ci/tools/check_noexcept.py` around lines 113 - 114, The function signatures
in this file use default parameter values which violates the repo rule; change
load_baseline(path: Path = DEFAULT_BASELINE) -> Counter[str] to remove the
default (load_baseline(path: Path) -> Counter[str]) and do the same for the
other flagged signatures in this file (the other two functions that currently
have defaulted parameters); ensure each parameter retains its explicit type
annotation, update all call sites to pass the required arguments (or hoist the
DEFAULT_* constant usage into the caller), and run linters/tests to confirm no
signature-rule violations remain.
Source: Coding guidelines
There was a problem hiding this comment.
Declining: a blanket no-default-parameter-values rule is not present in agents/docs/python-standards.md. Default values are widely used in this repo (e.g. ci/boards.py, ci/run_tests.py). The defaults here (DEFAULT_BASELINE, scope="all") are intentional ergonomics that match how the CLI invokes the API.
|
|
||
| new_hits, stale = check_noexcept.diff_against_baseline(hits, baseline) | ||
|
|
||
| assert [hit.line for hit in new_hits] == [11, 12] |
There was a problem hiding this comment.
Replace the list comprehension assertion setup with an explicit loop.
Line 70 uses a list comprehension where this codebase requires explicit loops for Python clarity/debuggability.
As per coding guidelines, "Use explicit loops instead of list comprehensions for code clarity and debuggability."
Proposed fix
- assert [hit.line for hit in new_hits] == [11, 12]
+ new_hit_lines: list[int] = []
+ for hit in new_hits:
+ new_hit_lines.append(hit.line)
+ assert new_hit_lines == [11, 12]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert [hit.line for hit in new_hits] == [11, 12] | |
| new_hit_lines: list[int] = [] | |
| for hit in new_hits: | |
| new_hit_lines.append(hit.line) | |
| assert new_hit_lines == [11, 12] |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ci/tools/test_check_noexcept.py` at line 70, Replace the list-comprehension
assertion in ci/tools/test_check_noexcept.py that checks [hit.line for hit in
new_hits] == [11, 12] with an explicit loop: create an explicit list or iterate
over new_hits using a for loop, collect or compare each hit.line against the
expected sequence (e.g., expected_lines = [11, 12]) and assert per-item equality
(or build the list with append and assert equality), referencing the variable
new_hits and the expected_lines array to improve clarity and debuggability.
Source: Coding guidelines
There was a problem hiding this comment.
Declining: agents/docs/python-standards.md does not ban list comprehensions, and they are used throughout ci/ (e.g. ci/tools/gh/ci_builds.py has 13). The single-line [hit.line for hit in new_hits] is clear and idiomatic in an assert.
Address CodeRabbit review feedback on PR #2987: - Avoid full-scope AST execution when run_noexcept_ast_check is called for a single file. Determine the owning scope ("fl" or "platforms") from the relative path and pass it to find_missing_noexcept, or skip the check entirely for files outside owned src scopes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Annotate `_legacy_violation_item_to_line_content` with explicit `Any` locals and use `cast` so pyright stops emitting reportUnknownVariableType / reportUnknownArgumentType for the legacy duck-typed code path. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… sigs Add a `third_party` scope to the AST-backed FL_NOEXCEPT ratchet: - New `ci/tools/_noexcept_check_third_party_tu.cpp` translation unit fed by `src/third_party/_build.cpp.hpp` (the existing unity-build header). - `ci/tools/check_noexcept.py` registers `third_party` in `_SCOPES` and includes it in `--scope all`. - `ci/lint_cpp/run_all_checkers.py` single-file fast-path detects `src/third_party/*` and pins the AST query to that scope. Annotated all FL_NOEXCEPT-missing signatures across 40 vendored files (TJpg_Decoder, cq_kernel, libhelix_mp3, libnsgif, mpeg1_decoder, pl_mpeg, stb_vorbis, stb_truetype, stb_hexwave). FL_NOEXCEPT is a no-op macro (`src/fl/stl/noexcept.h`), so this is purely a lint annotation with no runtime/compile impact. Each modified source/header now includes `fl/stl/noexcept.h`. `uv run python ci/tools/check_noexcept.py --scope third_party --no-baseline` reports 0 violations. `bash lint` passes. Also refactor `_legacy_violation_item_to_line_content` in run_all_checkers.py into two helpers so pyright stops tripping on the post-isinstance narrowed `tuple[Unknown, ...] | Any` type without needing a redundant cast that ty flags. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add FL_NOEXCEPT to CRGB operators, fl::stl containers, math/gamma helpers, delay routines, and clockless/SPI platform drivers to satisfy the FL_NOEXCEPT lint ratchet (#2987) and enable noexcept optimizations. Co-authored-by: Claude Opus 4.7 <[email protected]>
Fixes #2984.
Summary
ci/tools/check_noexcept.pythe default AST-backed FL_NOEXCEPT ratchet forsrc/fl/**andsrc/platforms/**Validation
uv run python -m pytest ci/tools/test_check_noexcept.py ci/lint_cpp/test_noexcept_checker.py ci/lint_cpp/test_noexcept_special_members_checker.py ci/lint_cpp/test_raw_noexcept_checker.pyuv run python ci/tools/check_noexcept.py --scope alluv run python ci/lint_cpp/run_all_checkers.pybash lint --cpp --no-fingerprint(passes; existing PlatformIO-internal-usage warnings remain warn-only)bash lint --no-fingerprint ci/tools/check_noexcept.py ci/tools/test_check_noexcept.py ci/lint_cpp/run_all_checkers.py ci/lint/stage_impls.py ci/lint.pyuv run python test.py --unit data --no-fingerprint --no-interactiveuv run python test.py --unit watchdog --no-fingerprint --no-interactiveSummary by CodeRabbit
New Features
Chores