Skip to content

fix: correct Python 2 except syntax in all auto-commit blocks#1

Open
phalt wants to merge 5 commits into
mainfrom
claude/review-architecture-refactoring-MB0i2
Open

fix: correct Python 2 except syntax in all auto-commit blocks#1
phalt wants to merge 5 commits into
mainfrom
claude/review-architecture-refactoring-MB0i2

Conversation

@phalt
Copy link
Copy Markdown
Owner

@phalt phalt commented May 11, 2026

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

claude added 5 commits May 11, 2026 15:36
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants