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

blue is incompatible with flake8 v5 #78

Open
RobertCraigie opened this issue Jul 31, 2022 · 9 comments · May be fixed by #96
Open

blue is incompatible with flake8 v5 #78

RobertCraigie opened this issue Jul 31, 2022 · 9 comments · May be fixed by #96

Comments

@RobertCraigie
Copy link

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.

@krcb197
Copy link

krcb197 commented Aug 1, 2022

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

@warsaw
Copy link
Collaborator

warsaw commented Aug 1, 2022

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.

@danigm
Copy link

danigm commented Sep 19, 2022

I think this patch will fix the issue

flake8-v5-compatibility.patch.txt

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Sep 19, 2022
https://build.opensuse.org/request/show/1004677
by user mcepl + dimstar_suse
- Add flake8-v5-compatibility.patch wich makes it work with flake8 v5
  gh#grantjenks/blue#78
@warsaw
Copy link
Collaborator

warsaw commented Oct 3, 2022

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

@sshishov
Copy link

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

@xmnlab
Copy link

xmnlab commented Jan 23, 2023

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

@sshishov
Copy link

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

@warsaw
Copy link
Collaborator

warsaw commented Mar 31, 2023

If you can, I'll review it.

@kaweantonio kaweantonio linked a pull request May 2, 2023 that will close this issue
@kaweantonio
Copy link

If you can, I'll review it.

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

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 a pull request may close this issue.

7 participants