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

Badly formatted output when running post-write hooks #1261

Closed
duc00 opened this issue Jun 15, 2023 · 3 comments
Closed

Badly formatted output when running post-write hooks #1261

duc00 opened this issue Jun 15, 2023 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@duc00
Copy link
Contributor

duc00 commented Jun 15, 2023

Describe the bug
There is a small output bug when running alembic revision ... with a post-write hook. The name of the hook is not correctly displayed:

$ alembic revision -m 'my new revision'        
  Generating myrepo/migrations/versions/202306151538_my_new_revision.py_ ...  done
  Running post write hook {name!r} ... # Display bug HERE
reformatted myrepo/migrations/versions/202306151538_my_new_revision.py

All done! ✨ 🍰 ✨
1 file reformatted.
  done

Happy to fix, if approved!

Expected behavior
This output

$ alembic revision -m 'my new revision'        
  Generating myrepo/migrations/versions/202306151538_my_new_revision.py_ ...  done
  Running post write hook black ... # Display bug HERE
reformatted myrepo/migrations/versions/202306151538_my_new_revision.py

All done! ✨ 🍰 ✨
1 file reformatted.
  done

when black hook is configured.

To Reproduce

$ mkdir testdir
$ cd testdir
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install alembic

Uncomment default post_write_hooks parameters in alembic.ini

[post_write_hooks]
black.type = console_scripts
black.entrypoint = black
black.options = -l 79 REVISION_SCRIPT_FILENAME

Then run revision command

alembic revision -m 'my new revision'

Error

# Command output
  Generating workspace/testdir/migrations/versions/324b3e655f54_my_new_revision.py ...  done
  Running post write hook {name!r} ...
...

Versions.

  • OS: macOS
  • Python: 3.11
  • Alembic: 1.11.1
  • SQLAlchemy: 2.0.16
  • Database: PostgreSQL 15.3
  • DBAPI: N/A

Additional context
Bug seems to be here:

with util.status("Running post write hook {name!r}", newline=True):

Have a nice day!

@duc00 duc00 added the requires triage New issue that requires categorization label Jun 15, 2023
@CaselIT
Copy link
Member

CaselIT commented Jun 15, 2023

Hi,

duh. thanks for noticing. strange that no linted said anything about it.
Care to create a PR for it?

@CaselIT CaselIT added bug Something isn't working good first issue Good for newcomers and removed requires triage New issue that requires categorization labels Jun 15, 2023
@duc00
Copy link
Contributor Author

duc00 commented Jun 17, 2023

Sure!

@sqla-tester
Copy link
Collaborator

Mathieu Défosse has proposed a fix for this issue in the main branch:

Fixed CLI output when running post_write hooks https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4731

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

Successfully merging a pull request may close this issue.

3 participants