You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
check_formatter_installed always returns True and doesn’t capture or propagate failures from format_code. Add error handling to detect and surface formatter invocation errors.
Wrap the call to format_code in a try-except to catch any errors (e.g., missing formatter executable or nonzero exit code) and raise a FormatterNotFoundError with a clear message. This preserves the original behavior of signaling failure instead of allowing unexpected exceptions to bubble up.
Why: Wrapping format_code in a try-except preserves the PR’s intention to detect missing or failing formatters and reintroduces raising FormatterNotFoundError, which is crucial for correct error signaling.
Medium
General
Ensure temp file always removed
Move the cleanup of tmp_file into a finally block to guarantee removal even if formatting fails. This prevents orphaned temp files when exceptions occur.
Why: Moving tmp_file.unlink(missing_ok=True) into a finally block improves robustness by guaranteeing cleanup even on exceptions, though it’s a minor enhancement.
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
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.
PR Type
Enhancement
Description
Use
format_codeto replace subprocess logicRemove manual formatter error handling
Import
format_codein env_utils moduleChanges walkthrough 📝
env_utils.py
Use `format_code` in formatter checkcodeflash/code_utils/env_utils.py
format_codefunctionformat_codecall