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

Set isort profile argument to "black" #4270

Closed

Conversation

JSv4
Copy link

@JSv4 JSv4 commented Apr 13, 2023

Description

There are some corner-cases where isort and black revert each other's changes and you can't resolve your code such that they're both happy. There's a related issue in the iSort repo (#1518) (PyCQA/isort#1518). Appears the solution is to use the "black" profile, which can be set in setup.cfg or .pre-commit-config.yaml. This change adds the profile arg to the .pre-commit-config.yaml file. This conflict can also be caused by intentionally setting inconsistent style settings for iSort and Black, but I don't believe I've changed your defaults and most of the time your settings work great.

I don't think this proposed change requires any changes to the docs or tests. This fixes the above issue for me when it does come up, and I thought it would be nice to have it right in the cookiecutter template, which I really like using as a base for my Django projects. I have some additional config tweaks I'd like to suggest as well and will submit those separately.

Checklist:

  • [X ] I've made sure that tests are updated accordingly (especially if adding or updating a template option)
  • [X ] I've updated the documentation or confirm that my change doesn't require any updates

Rationale

I've run into this Black/iSort conflict a handful of times in the years I've used your template. Each time I encounter it, I need to go look up how to fix it. Seems like it'd be good to just roll the fix right into the Django Cookiecutter master branch?

There are some corner-cases where isort and black revert each other's changes and you can't resolve your code such that they're both happy. There's a related issue in the iSort repo (cookiecutter#1518) (PyCQA/isort#1518). Appears the solution is to use the "black" profile, which can be set in setup.cfg or .pre-commit-config.yaml. This change adds the profile arg to the .pre-commit-config.yaml file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant