fix: correct Python 2 except syntax in all auto-commit blocks#1
Open
phalt wants to merge 5 commits into
Open
Conversation
Seven occurrences of `except ExcA, ExcB:` (Python 2 syntax) were scattered across cli.py, commands/alias.py, and commands/tool.py. In Python 3 this is a SyntaxError that only surfaces when the code path runs, not at import time — meaning every command that attempts an auto-commit after a mutation would crash silently on its happy path. Changed to `except (ExcA, ExcB):` throughout. https://claude.ai/code/session_01HPtPpBAwQqSjXFafTPQYu9
The same 6-line try/except pattern — load config, check auto_commit, call git.commit, print confirmation — appeared seven times across cli.py, commands/alias.py, and commands/tool.py. Any change to the auto-commit contract (e.g. a new exception type, a dry-run guard, or a log line) had to be applied in seven places; one would inevitably be missed. Each file now has a private _maybe_commit(repo_path, message) helper that owns this logic once. The three files are kept separate rather than sharing a single helper because they are independent command modules that don't otherwise import each other. https://claude.ai/code/session_01HPtPpBAwQqSjXFafTPQYu9
display.py is the established home for all rich display helpers, but print_tool_results (and its _TOOL_ACTION_LABELS dict) lived in commands/tool.py — a command module. This forced cli.py to reach into a command module just to render the apply summary, and left display.py as an incomplete reference for display logic. Moved both to display.py alongside the other _*_LABELS dicts and print_* functions. commands/tool.py now imports display and calls display.print_tool_results for tool_install and tool_update output. cli.py._print_apply_result does the same. https://claude.ai/code/session_01HPtPpBAwQqSjXFafTPQYu9
The status command called state.load_state() twice in two separate try/except blocks, assigning to 's' and 'ss' respectively. Both reads hit the same file on disk and held the same value. The second call and the separate try/except existed only to give print_status_attention a variable to work with. Moved print_status_attention(s) inside the existing try block so the file is read once and both uses share the same result. If state.toml is missing, both the dotfiles status check and the attention banner are skipped together, which is the correct behaviour. https://claude.ai/code/session_01HPtPpBAwQqSjXFafTPQYu9
add_tool_to_profile and add_dotfile_to_profile mutate profile TOML files via raw dicts rather than round-tripping through ProfileConfig. This is intentional: loading and re-dumping through the model would silently drop any keys added by a newer pauldot version (forward compatibility). However, the raw string literals "tools" and "dotfiles" had no visible connection to ProfileConfig.tools and ProfileConfig.dotfiles, so a field rename would not be caught. Introduced _PROFILE_FIELD_TOOLS and _PROFILE_FIELD_DOTFILES constants with inline comments naming the model fields they correspond to. The constants act as a single point of update and make the coupling reviewable, without changing the raw-dict approach that preserves unknown keys. https://claude.ai/code/session_01HPtPpBAwQqSjXFafTPQYu9
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.
Seven occurrences of
except ExcA, ExcB:(Python 2 syntax) werescattered across cli.py, commands/alias.py, and commands/tool.py.
In Python 3 this is a SyntaxError that only surfaces when the code
path runs, not at import time — meaning every command that attempts
an auto-commit after a mutation would crash silently on its happy
path. Changed to
except (ExcA, ExcB):throughout.https://claude.ai/code/session_01HPtPpBAwQqSjXFafTPQYu9