Repository navigation
fix(wasm): map FastLED DWARF source paths - #2675
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR normalizes rglob output paths to forward slashes, adds versioned source-metadata cache data via CACHE_VERSION and CacheEntry with validation, and emits -ffile-prefix-map DWARF flags for debug/fast_debug modes with tests and TOML guidance. ChangesBuild System Infrastructure and DWARF Debug Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
ci/meson/src_metadata_cache.py (2)
78-91:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle KeyboardInterrupt before other exceptions.
The try-except block does not handle
KeyboardInterruptbefore catching other exceptions. As per coding guidelines, all Python try-catch blocks must handleKeyboardInterruptbefore other exceptions to ensure proper cleanup and prevent masking user interruptions.🛡️ Proposed fix to handle KeyboardInterrupt
try: with open(cache_file, "r", encoding="utf-8") as f: cache = json.load(f) # Validate cache structure required_keys = ["version", "hash", "timestamp", "metadata"] if not all(key in cache for key in required_keys): return None if cache["version"] != CACHE_VERSION: return None return cache + except KeyboardInterrupt: + raise except (json.JSONDecodeError, OSError): return NoneAs per coding guidelines: "All Python try-catch blocks must handle KeyboardInterrupt before other exceptions".
🤖 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/meson/src_metadata_cache.py` around lines 78 - 91, The try-except around reading/parsing the cache (the block that opens cache_file and calls json.load and checks CACHE_VERSION) must handle KeyboardInterrupt first; add an explicit except KeyboardInterrupt: raise before the existing except (json.JSONDecodeError, OSError): return None so that user interrupts aren’t swallowed and normal JSON/OSError handling remains unchanged.
63-63: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy liftReturn a dataclass instead of dict for type safety.
The function returns
dict[str, str | float] | Nonewith multiple fields (version, hash, timestamp, metadata). As per coding guidelines, functions with multiple return values should return dataclass structs instead of tuples or dicts for better type safety and maintainability.♻️ Proposed refactor to use dataclass
Add a dataclass definition near the top of the file:
from dataclasses import dataclass from typeguard import typechecked `@typechecked` `@dataclass` class CacheEntry: version: int hash: str timestamp: float metadata: strThen update the function signature:
-def load_cache(build_dir: Path) -> dict[str, str | float] | None: +def load_cache(build_dir: Path) -> CacheEntry | None: """ Load cached source metadata from build directory. Args: build_dir: Meson build directory (e.g., .build/meson-quick/) Returns: - Cache dictionary with keys: hash, timestamp, metadata + CacheEntry with version, hash, timestamp, and metadata None if cache doesn't exist or is invalid """Update the validation and return logic:
# Validate cache structure required_keys = ["version", "hash", "timestamp", "metadata"] if not all(key in cache for key in required_keys): return None if cache["version"] != CACHE_VERSION: return None - return cache + return CacheEntry( + version=cache["version"], + hash=cache["hash"], + timestamp=cache["timestamp"], + metadata=cache["metadata"] + )Update call sites in
main()to use dataclass fields instead of dict keys.As per coding guidelines: "Return dataclass structs instead of tuples or dicts for functions with multiple return values" and "Use
@typecheckeddecorator with@dataclassfor runtime type validation".🤖 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/meson/src_metadata_cache.py` at line 63, Replace the loose dict return from load_cache with a typed dataclass: add a `@typechecked` `@dataclass` CacheEntry (fields: version:int, hash:str, timestamp:float, metadata:str) near the top of the module, change load_cache signature to return Optional[CacheEntry] instead of dict[str, str|float] | None, map/validate the parsed values into a CacheEntry instance before returning, and update all call sites (e.g., usages in main()) to access entry.version/entry.hash/entry.timestamp/entry.metadata instead of dict keys.
🧹 Nitpick comments (1)
ci/tests/test_wasm_flags.py (1)
30-30: 💤 Low valueUse an explicit loop instead of the generator expression.
♻️ Proposed change
- assert not any(flag.startswith("-ffile-prefix-map=") for flag in flags) + for flag in flags: + assert not flag.startswith("-ffile-prefix-map=")As per coding guidelines: "Use explicit loops instead of list comprehensions for code clarity and debuggability".
🤖 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/tests/test_wasm_flags.py` at line 30, The assertion uses a generator expression; replace it with an explicit loop over the flags iterable to improve clarity and debuggability: iterate through flags, check each flag.startswith("-ffile-prefix-map="), and if any matches call an explicit test failure (e.g., pytest.fail or assert False with a message) referencing the offending flag; update the line containing the assertion on the flags variable to use this loop and provide a clear failure message.
🤖 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/wasm_flags.py`:
- Around line 64-69: The list comprehension in _file_prefix_map_flags should be
rewritten as an explicit loop to follow the guideline; replace the comprehension
that builds the list of "-ffile-prefix-map" entries with creating an empty list,
iterating over the iterator returned by _path_prefix_variants(from_path),
appending each formatted f"-ffile-prefix-map={path_prefix}={normalized_prefix}"
string to the list, and then return that list — keep the existing normalization
of to_prefix and the use of _path_prefix_variants as the source of path_prefix
values.
---
Outside diff comments:
In `@ci/meson/src_metadata_cache.py`:
- Around line 78-91: The try-except around reading/parsing the cache (the block
that opens cache_file and calls json.load and checks CACHE_VERSION) must handle
KeyboardInterrupt first; add an explicit except KeyboardInterrupt: raise before
the existing except (json.JSONDecodeError, OSError): return None so that user
interrupts aren’t swallowed and normal JSON/OSError handling remains unchanged.
- Line 63: Replace the loose dict return from load_cache with a typed dataclass:
add a `@typechecked` `@dataclass` CacheEntry (fields: version:int, hash:str,
timestamp:float, metadata:str) near the top of the module, change load_cache
signature to return Optional[CacheEntry] instead of dict[str, str|float] | None,
map/validate the parsed values into a CacheEntry instance before returning, and
update all call sites (e.g., usages in main()) to access
entry.version/entry.hash/entry.timestamp/entry.metadata instead of dict keys.
---
Nitpick comments:
In `@ci/tests/test_wasm_flags.py`:
- Line 30: The assertion uses a generator expression; replace it with an
explicit loop over the flags iterable to improve clarity and debuggability:
iterate through flags, check each flag.startswith("-ffile-prefix-map="), and if
any matches call an explicit test failure (e.g., pytest.fail or assert False
with a message) referencing the offending flag; update the line containing the
assertion on the flags variable to use this loop and provide a clear failure
message.
🪄 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: 18e454f2-bc0d-42c1-97bd-17aa9d849f5e
📒 Files selected for processing (5)
ci/meson/rglob.pyci/meson/src_metadata_cache.pyci/tests/test_wasm_flags.pyci/wasm_flags.pysrc/platforms/wasm/compiler/build_flags.toml
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
ci/meson/src_metadata_cache.py (2)
62-63:⚠️ Potential issue | 🟠 Major | ⚡ Quick winMove import to top of file.
The
from os import stat_resultimport is inside the function body. All system imports must be at the top of the file.📦 Proposed fix to move import to top-level
Add the import at the top of the file with other standard library imports:
import argparse import hashlib import json +from os import stat_result import sys from dataclasses import dataclass from pathlib import PathThen remove the inline import from the function:
hash_input: list[str] = [] for f in source_files: if f.is_file(): - from os import stat_result - stat: stat_result = f.stat()As per coding guidelines: "All system imports must be at the top of the file in proper order: standard library, third-party, local".
🤖 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/meson/src_metadata_cache.py` around lines 62 - 63, The inline import "from os import stat_result" must be moved to the module top with the other standard-library imports; remove the in-function import and add "from os import stat_result" alongside existing imports at the top of the file so functions (e.g., wherever stat_result was used) reference the top-level symbol instead of importing at runtime.
137-137:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd
argvparameter tomain()for testing flexibility.The
main()function should accept an optionallist[str]parameter to enable passing test arguments toparse_args().🧪 Proposed fix to add argv parameter
-def main() -> None: +def main(argv: list[str] | None = None) -> None: """Main entry point for source metadata cache operations.""" parser = argparse.ArgumentParser( description="Manage source metadata cache for Meson build system"Then update the parse_args call at line 180:
- args = parser.parse_args() + args = parser.parse_args(argv)As per coding guidelines: "parse_args functions MUST accept an optional list[str] parameter for testing flexibility".
🤖 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/meson/src_metadata_cache.py` at line 137, Update the main function signature to accept an optional argv parameter (e.g., def main(argv: Optional[list[str]] = None) -> None) and pass that argv into the existing parse_args call (replace parse_args() with parse_args(argv)) so tests can inject arguments; reference the main() function and the parse_args() invocation for the change and include the appropriate typing import if needed.
🤖 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/meson/src_metadata_cache.py`:
- Line 41: The function compute_src_files_hash currently declares pattern with a
default value; remove the default so the signature is def
compute_src_files_hash(src_dir: Path, pattern: str) -> str, and update every
call site to pass the desired pattern explicitly (e.g., "*.cpp" where previously
relied upon the default). Ensure any tests or internal usages that omitted the
pattern are updated to supply an explicit string and run the test suite to
verify nothing else depends on the default.
- Around line 31-38: The CacheEntry dataclass lacks the `@typechecked` decorator
for runtime type validation; import typechecked from typeguard and apply
`@typechecked` above the CacheEntry declaration so that the class CacheEntry (with
fields version, hash, timestamp, metadata) is validated at runtime. Ensure the
new import is added alongside other imports and the decorator is placed
immediately above the `@dataclass`(frozen=True) line referencing CacheEntry.
---
Outside diff comments:
In `@ci/meson/src_metadata_cache.py`:
- Around line 62-63: The inline import "from os import stat_result" must be
moved to the module top with the other standard-library imports; remove the
in-function import and add "from os import stat_result" alongside existing
imports at the top of the file so functions (e.g., wherever stat_result was
used) reference the top-level symbol instead of importing at runtime.
- Line 137: Update the main function signature to accept an optional argv
parameter (e.g., def main(argv: Optional[list[str]] = None) -> None) and pass
that argv into the existing parse_args call (replace parse_args() with
parse_args(argv)) so tests can inject arguments; reference the main() function
and the parse_args() invocation for the change and include the appropriate
typing import if needed.
🪄 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: 4e7ca668-1c7e-4d5c-a5fb-a511b1754d15
📒 Files selected for processing (3)
ci/meson/src_metadata_cache.pyci/tests/test_wasm_flags.pyci/wasm_flags.py
🚧 Files skipped from review as they are similar to previous changes (2)
- ci/tests/test_wasm_flags.py
- ci/wasm_flags.py
Summary
Refs FastLED/cli#130.
Tests
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation