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

--code doesn't work with --check or --diff #1801

Closed
ajeetdsouza opened this issue Nov 2, 2020 · 0 comments · Fixed by #2259
Closed

--code doesn't work with --check or --diff #1801

ajeetdsouza opened this issue Nov 2, 2020 · 0 comments · Fixed by #2259
Labels
C: configuration CLI and configuration T: bug Something isn't working

Comments

@ajeetdsouza
Copy link

Describe the bug

  • --code is supposed to take the code as an input string
  • --check is supposed to change the exit code based on whether edits were made while formatting
  • --diff is supposed to only output a diff, instead of the entire formatted source

What I found was the the --check and --diff flags did not work when passing input using --code; it behaved as if the extra flags hadn't been passed at all.

To Reproduce Steps to reproduce the behavior:

  1. Run this command (notice the double space after =):
black --check --code 'a =  5'
  1. The command exits with a status 0, despite making edits (removing the double space).

Expected behavior The command should have exited with a status of 1, since edits were made.

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: Arch Linux/Python 3.8.6
@ajeetdsouza ajeetdsouza added the T: bug Something isn't working label Nov 2, 2020
@ichard26 ichard26 added the C: configuration CLI and configuration label Nov 2, 2020
JelleZijlstra pushed a commit that referenced this issue Jun 2, 2021
Properly handles the diff, color, and fast option when black is run with
 the `--code` option.

Closes #2104, closes #1801.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration CLI and configuration T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants