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

error: cannot format /home/wojtek/workspace/portal/pustasz/apps/categories/permissions.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter. #1920

Closed
wojwarych opened this issue Jan 11, 2021 · 2 comments
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@wojwarych
Copy link

wojwarych commented Jan 11, 2021

Describe the bug A clear and concise description of what the bug is.
Formatting with black via pre-commit hook cannot find a way to properly format style in long and complex if/else statements

To Reproduce Steps to reproduce the behavior:
See Additional context paragraph for settings and file content which causes an error.

  1. Create git repo and add error-prone file
  2. Install pre-commit in venv and add black hook to .yaml config
  3. Stage the file
  4. git commit -m "foo"
  5. Pre-commit fails to format this file, spits out an error

Expected behavior A clear and concise description of what you expected to happen.
Pre-commit fails in the first run, but it gives a formatting solution for a file. After fixing formatting pre-commit passes for black.

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: Ubuntu 20.04/Python 3.7.9

Does this bug also happen on master?
Yes, it does. I've run file content on online formatter and it spits out same error as in title:

Additional context Add any other context about the problem here.
pyproject.toml config:

[tool.black]
line-length = 79
target-version = ["py37"]
exclude = "/(env|workers|migrations)/"

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 79

pre-commit config:

default_language_version:
    python: python3.7
repos:
-   repo: https://github.com/psf/black
    rev: 20.8b1
    hooks:
    -   id: black
        language_version: python3.7
        exclude: .*\/migrations\/.*.py

File is added as a .txt attachement

Thanks for help in advance!
permissions.txt

@wojwarych wojwarych added the T: bug Something isn't working label Jan 11, 2021
@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Jan 11, 2021
@mvolfik
Copy link

mvolfik commented Feb 22, 2021

I'm not sure if there's some more to the pre-commit part, I just tested running black --line-length 79 file.py. However, that fails on master, but succeeds with #1958 checked out, so this is likely a duplicate of #1629

@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 25, 2021
@ichard26
Copy link
Collaborator

Hello!

All reproduction cases in this issue format without error on master. The fixing commit was 8672af3 from PR GH-2126. I'll be marking this issue as a duplicate of GH-1629 since that's what GH-2126 aimed to fix and it's highly likely this issue falls under GH-1629.

Since we use the issue tracker as a reflection of what's on master, I'll be closing this issue. If you have any issues, especially with the new (but stable) output, please open a new issue. Oh and the fix should be available in a published release soon, see GH-2125 for more info.

Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants