blue icon indicating copy to clipboard operation
blue copied to clipboard

blue is incompatible with flake8 v5

Open RobertCraigie opened this issue 3 years ago • 9 comments

Flake8 v5 was just released earlier today. Unfortunately this breaks blue as it now crashes with this error:

Traceback (most recent call last):
  File "/tmp/tox/prisma-client-py/lint/lib/python3.9/site-packages/blue/__init__.py", line 397, in <module>
    BaseConfigParser = flake8_config.ConfigParser              # flake8 v4
AttributeError: module 'flake8.options.config' has no attribute 'ConfigParser'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/tox/prisma-client-py/lint/bin/blue", line 5, in <module>
    from blue import main
  File "/tmp/tox/prisma-client-py/lint/lib/python3.9/site-packages/blue/__init__.py", line 399, in <module>
    BaseConfigParser = flake8_config.MergedConfigParser        # flake8 v3
AttributeError: module 'flake8.options.config' has no attribute 'MergedConfigParser'

Constraining the flake8 dependency to v4 fixes the error.

RobertCraigie avatar Jul 31 '22 01:07 RobertCraigie

I have been able to work around this problem by adding a dependency in setup.py for my project on flake8<=4.0.1, the same workaround can be done in a requirements.txt

krcb197 avatar Aug 01 '22 15:08 krcb197

Okay, this does look like a trickier incompatibility to resolve. It looks like flake8 didn't just change the name of the config class, they changed the way they parse the configs. So I think for now, a quick fix is the pin in #79 but we should leave this issue open pending a proper fix.

warsaw avatar Aug 01 '22 16:08 warsaw

I think this patch will fix the issue

flake8-v5-compatibility.patch.txt

danigm avatar Sep 19 '22 11:09 danigm

I think this patch will fix the issue

Unfortunately, not completely. With this change as well:

modified   setup.py
@@ -37,7 +37,7 @@ setup(
     packages=['blue'],
     tests_require=['tox'],
     cmdclass={'test': Tox},
-    install_requires=['black==22.1.0', 'flake8>=3.8,<5.0.0'],
+    install_requires=['black==22.1.0', 'flake8>=3.8'],
     project_urls={
         'Documentation': 'https://blue.readthedocs.io/en/latest',
         'Source': 'https://github.com/grantjenks/blue.git',

(i.e. remove the flake8 ceiling), I get the following errors:

ctx = <click.core.Context object at 0x10a5d84f0>, param = <Option config>, value = None

    def read_configs(
        ctx: click.Context, param: click.Parameter, value: Optional[str]
    ) -> Optional[str]:
        """Read configs through the config param's callback hook."""
        # Use black's `read_pyproject_toml` for the default
        result = black.read_pyproject_toml(ctx, param, value)
        # Use flake8's config file parsing to load setup.cfg, tox.ini, and .blue
        # The parsing looks both in the project and user directories.
>       finder = flake8_config.ConfigFileFinder('blue')
E       AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder'

/Users/barry/projects/blue/blue/__init__.py:424: AttributeError

warsaw avatar Oct 03 '22 19:10 warsaw

Could we guys fix the issue? The issue is open for half of the year. Flake8 has already v6 btw

sshishov avatar Dec 16 '22 12:12 sshishov

hey everyone, any plan for supporting flake8 v5 and v6?

xmnlab avatar Jan 23 '23 03:01 xmnlab

@xmnlab I guess we have to come up with pull request for this to support it. Otherwise the issue will be open for years...

sshishov avatar Mar 30 '23 22:03 sshishov

If you can, I'll review it.

warsaw avatar Mar 31 '23 01:03 warsaw

If you can, I'll review it.

Hi, @warsaw, I opened PR #96 to fix this issue. Can you review it?

kaweantonio avatar May 02 '23 01:05 kaweantonio