Skip to content

Comments

Let interactive prompt changes respect dynamic format strings#1603

Merged
rolandwalker merged 1 commit intomainfrom
RW/interactive-prompt-change-dynamic-values
Feb 24, 2026
Merged

Let interactive prompt changes respect dynamic format strings#1603
rolandwalker merged 1 commit intomainfrom
RW/interactive-prompt-change-dynamic-values

Conversation

@rolandwalker
Copy link
Contributor

@rolandwalker rolandwalker commented Feb 21, 2026

Description

The interactive prompt command was calling get_prompt() to set the prompt format. But get_prompt() computes the substituted values of any format strings.

Therefore the interactive prompt command was "burning in" any dynamically-computed values such as the date or the database name as a static value.

This is a bug, and it differs from the behavior of setting the prompt option in ~/.myclirc, which works correctly here.

The fix is to set the prompt format directly to the argument to change_prompt_format(), because the argument is a format string.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Feb 21, 2026
@github-actions
Copy link

Findings

  1. Missing test coverage: there’s no test asserting that interactive prompt changes keep dynamic placeholders (e.g., \\D, \\d) and update on subsequent prompts. Consider adding a test that sets the prompt via the interactive command, then changes the database or advances time and verifies the prompt re-renders with fresh values. mycli/main.py:424

Notes

  • No correctness or security regressions spotted in the code change itself.

Suggested next steps

  1. Add a CLI/integration test for prompt command with dynamic format tokens.

@rolandwalker rolandwalker force-pushed the RW/interactive-prompt-change-dynamic-values branch from cdfb6fb to 7a5c642 Compare February 23, 2026 09:41
The interactive "prompt" command was calling get_prompt() to set the
prompt format.  But get_prompt() computes the substituted values of any
format strings.

Therefore the interactive "prompt" command was burning in any
dynamically-computed values such as the date or the database name as
a static value.

This is a bug, and it differs from the behavior of setting the prompt
option in ~/.myclirc, which works correctly here.

The fix is to set the prompt format directly to the argument to
change_prompt_format(), because the argument _is_ a format string.
@rolandwalker rolandwalker force-pushed the RW/interactive-prompt-change-dynamic-values branch from 7a5c642 to d83fcdf Compare February 24, 2026 09:35
@rolandwalker rolandwalker merged commit c448afc into main Feb 24, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/interactive-prompt-change-dynamic-values branch February 24, 2026 09:39
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