Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alembic.util.messaging.msg does not properly wrap at terminal width #1384

Closed
saifelse opened this issue Jan 5, 2024 · 2 comments
Closed
Labels
bug Something isn't working command interface

Comments

@saifelse
Copy link
Contributor

saifelse commented Jan 5, 2024

Describe the bug
When alembic prints longs messages to stdout, it attempts to wrap messages at the terminal width.
However, it wraps 2 characters wider than the message.

Expected behavior
Messages should properly wrap at the width of the terminal.

To Reproduce
In a fairly narrow terminal window (e.g. 64 columns wide), run:

python -c 'from alembic.util.messaging import msg; msg("A" * 500)'

Output:

  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Expected:

  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  AAAA

Versions.

  • OS: macOS 14.1.2
  • Python: 3.11.6
  • Alembic: 1.13.1
  • SQLAlchemy: N/A
  • Database: N/A
  • DBAPI: N/A

Additional context
Fun fact: this bug was introduced all the way back in d4fea1d!
The message is wrapped at the terminal width, but then two spaces are prepended to every line.

Have a nice day!

@saifelse saifelse added the requires triage New issue that requires categorization label Jan 5, 2024
saifelse added a commit to benchling/alembic that referenced this issue Jan 5, 2024
Instead of applying indent manually after using textwrap, simply use the
`textwrap.wrap`'s `initial_indent` / `subsequent_indent` that will taken into
account when wrapping to the specified `width`

Fixes: sqlalchemy#1384
@CaselIT
Copy link
Member

CaselIT commented Jan 5, 2024

Hi,

Thanks for reporting and for the PR!

@CaselIT CaselIT added bug Something isn't working command interface and removed requires triage New issue that requires categorization labels Jan 5, 2024
@sqla-tester
Copy link
Collaborator

Saif Hakim has proposed a fix for this issue in the main branch:

fix alembic.util.messaging.msg to properly wrap at terminal width https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/5082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working command interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants