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

Pre-commit hook stuck in a file formatting loop #45318

Closed
mduran80 opened this issue Jan 19, 2021 · 1 comment · Fixed by #45321
Closed

Pre-commit hook stuck in a file formatting loop #45318

mduran80 opened this issue Jan 19, 2021 · 1 comment · Fixed by #45321

Comments

@mduran80
Copy link
Contributor

The problem

I am trying to upload a new integration for Daikin Madoka thermostats but the pre-commit hook is stuck in a loop where either "black" or "isort" always fail as both try to update the file and the exit code is interpreted as an error. I have tried to modify the imports or reduce them without any success.

Please find attached one of the files that fails. Run "black init.py" and then "isort __init__py" and again "black init.py". The files are always changed so the pre-commit hook fails.

This is the failing pull-request:

#45314

init.py.zip

I have disabled the isort job in my local environment, but it is run anyway when uploading to github.

Environment

  • Home Assistant Core release with the issue:
  • Last working Home Assistant Core release (if known):
  • Operating environment (OS/Container/Supervised/Core):
  • Integration causing this issue:
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

@mduran80
Copy link
Contributor Author

The pre-commit-config.yaml should include the following args for isort:

- repo: https://github.com/PyCQA/isort
    rev: 5.5.3
    hooks:
      - id: isort
        args:
          - --profile
          - black

https://pycqa.github.io/isort/docs/configuration/black_compatibility/

mduran80 added a commit to mduran80/core that referenced this issue Jan 19, 2021
The pre-commit hook gets stuck in a file formatting loop where black and isort modify each other results. According to the isort webpage, the option --profile black has to be used to enhance compatibility. This has been run successfully in my local and has solved the loop.

See:
home-assistant#45318
home-assistant#45314
cgarwood pushed a commit that referenced this issue Jan 20, 2021
…ck (#45321)

The pre-commit hook gets stuck in a file formatting loop where black and isort modify each other results. According to the isort webpage, the option --profile black has to be used to enhance compatibility. This has been run successfully in my local and has solved the loop.

See:
#45318
#45314
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant