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

feat: remove flake8 dependency #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kaweantonio
Copy link

Fixes: #78

Blue relies on flake8 to parse config files like 'setup.cfg', 'tox.ini' and '.blue'. This was done using ConfigParser and ConfigFileFinder classes, but in flake8 v5/6 these classes have been removed.

To fix the problem, all flake8 related code was removed and replace with a new function that parses the config files. This is all done using ConfigParser class from configparser module.

The new function is largely inspired by Flake8 own implementation, mainly the load_config and parse_config functions.

@kaweantonio
Copy link
Author

@warsaw can you review this PR?

Copy link

@krcb197 krcb197 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to look at this, it does seem like it will be an improvement but I am not sure it does everything that that black would do with configuration files (I think the aim is to match the behaviour with the name changed). The alternative would be changing the documentation to describe the simpler set of things Blue does.

I suggest it needs some testing. Can a pre-release be made?

In particular looking at the where black looks for configuration , this suggests that:

  • It will look recursively starting from the current working directory, not sure this fix behaves quite the same
  • it will look for a global file in the HOME directory
  • it will use a [tool.black] section in a toml file.

The logic Black implements can be found in files.py

blue/__init__.py Outdated Show resolved Hide resolved
@kaweantonio
Copy link
Author

kaweantonio commented May 3, 2023

@krcb197 The fix only looks in the current working directory, but shouldn't be hard to improve load_configs_from_file to match Black behavior/logic. I'll update my PR in the next days to include this change.

@kaweantonio
Copy link
Author

@krcb197 PR updated applying Black logic for config files. Waiting for your review :)

@krcb197
Copy link

krcb197 commented May 8, 2023

Looks good to me

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.

blue is incompatible with flake8 v5
2 participants