Skip to content

Conversation

@dedi
Copy link
Contributor

@dedi dedi commented May 31, 2022

Why this is needed:
In flake8, support for multiple ignores for the same pattern is allowed, but is currently not supported by the flake8 plugin.
If I have something like the following in my project's setup.cfg file:

[flake8]
per-file-ignores = __init__.py: F401, F403

Then running flake8 manually from the command line seems to behave as expected (ignore errors F401 and F403 from all __init__.py files), but running it from inside pylsp causes an error to be written to the log, and flake8 doesn't actually run. This small and admittedly not very elegant piece of code lets the flake8 plugin accept such a configuration.

(In fact, with my version of flake8 (3.8.4), I couldn't find any way to write the above which would work both under pylsp and when running flake8 manually. A configuration of the form

[flake8]
per-file-ignores = 
    __init__.py: F401
    __init__.py: F403

which seem to be valid according to the flake8 spec, doesn't actually make flake8 ignore both errors, so this fix is the only way I found to have a configuration which behaves identically when running either manually or under pylsp)

(edit: some typos. Sorry).

@ccordoba12
Copy link
Member

Hey @dedi, thanks a lot for your contribution! Could you add a test for this? That way it won't regress in the future.

@dedi
Copy link
Contributor Author

dedi commented May 31, 2022

Sure, sorry I missed that. The regression test is now there.

@ccordoba12 ccordoba12 added this to the v1.5.0 milestone May 31, 2022
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

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

Thanks for your help @dedi!

@ccordoba12 ccordoba12 changed the title Allow multiple per-file-ignores for the same pattern in flake8 plugin. Allow multiple per-file-ignores for the same pattern in flake8 plugin May 31, 2022
@ccordoba12 ccordoba12 merged commit 66c7cca into python-lsp:develop May 31, 2022
@dedi dedi deleted the flake8-fix-per-file-ignores branch June 1, 2022 04:54
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.

2 participants