grantjenks / blue

The slightly less uncompromising Python code formatter.
https://blue.readthedocs.io/
Other
387 stars 21 forks source link

Relax flake8 versions to support flake8 v4+ #56

Closed browniebroke closed 2 years ago

browniebroke commented 2 years ago

I recently tried to add blue to a project along with the latest flake8 (4.0.1) but I was suprised to see that it failed to install due to conflict:

The conflict is caused by:
    The user requested flake8~=4.0
    blue 0.7.0 depends on flake8==3.8.4

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

Trying to relax the version requested for flake8 so that blue can be installed alongside other tools.

browniebroke commented 2 years ago

Ok, that's not working... Nevermind:

Traceback (most recent call last):
  File "/home/runner/work/blue/blue/.tox/bluecheck/bin/blue", line 5, in <module>
    from blue import main
  File "/home/runner/work/blue/blue/.tox/bluecheck/lib/python3.9/site-packages/blue/__init__.py", line 335, in <module>
    class MergedConfigParser(flake8_config.MergedConfigParser):
AttributeError: module 'flake8.options.config' has no attribute 'MergedConfigParser'
grantjenks commented 2 years ago

Hi @browniebroke — I’ve had this concern for a while. Our dependencies make it harder to “play nice” with other packages. At work and for my personal projects this is less of an issue because the tools use isolated virtual environments. So the venv used for Blue is different than the venv used for Flake8. If you use a tool like “tox” then it’ll do this setup for you.

Otherwise we need to make the code in blue tolerant of different flake8 packages or vendor the code out of flake8.