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

Official API for seeing selected error codes / document existing way of doing it #1776

Closed
jakkdl opened this issue Dec 28, 2022 · 4 comments
Closed

Comments

@jakkdl
Copy link

jakkdl commented Dec 28, 2022

describe the request

When implementing python-trio/flake8-async#91 I wanted to be able to access what error codes have been selected/ignored by the user.
https://flake8.pycqa.org/en/latest/plugin-development/plugin-parameters.html#registering-options mentions creating a parallel --select option, but having to register --select, --ignore, --extend-select, --extend-ignore etc and also recreating flake8's complicated logic for those seemed like a foolish task - and I ended up working around that by importing DecisionEngine and Decision from flake8.style_guide. It ended up working fairly well, though it became very involved to get it working in my tests - also needing to import flake8.main.options.register_default_options and manually adding extended_default_select and extended_default_ignore to get DecisionEngine.decision_for to work.

It all works in the end, but this seems like something that maybe should be easily accessible without having to delve into flake8's code and yank out undocumented functionality that one cannot rely on being stable.

@sigmavirus24
Copy link
Member

You've explained that you want to do this, not why and without that, the default answer is no.

Also, nothing except what is documented as the public API is guaranteed to exist long term or to remain where you're importing it from.

@sigmavirus24
Copy link
Member

Your pull request also doesn't explain why. It looks like you're adding custom behavior that would otherwise be a flake8 (not plugin) behavior and you're trying to shoehorn something into flake8 that will almost certainly break in the future just by the normal course of development here. At this point, it seems like you should be creating a custom linter CLI, not a flake8 plugin, and I thoroughly implore you to consider that option if you're intent on continuing down the path you're taking there. Flake8 isn't designed to support your needs there nor should it be

@jakkdl
Copy link
Author

jakkdl commented Dec 28, 2022

You've explained that you want to do this, not why and without that, the default answer is no.

The reason is to speed up the plugin when disabling checks and to ease debugging while developing for stepping through the visitor.
Disabling expensive checks is a thing that pycodestyle does when run natively (though not when imported as a plugin like you do), and discussed in #751 whether to do it for flake8's checks (and for whole plugins).

Also, nothing except what is documented as the public API is guaranteed to exist long term or to remain where you're importing it from.

of course, which is why I'm asking for an official API for doing it. I made sure to implement it in flake8-trio in a way that would be relatively easy to disable if/when it breaks in flake8.

It looks like you're adding custom behavior that would otherwise be a flake8 (not plugin) behavior

Flake8 could maybe disable a whole plugin, but I don't see how it could disable parts of a plugin depending on which checks are selected.

@asottile
Copy link
Member

you can use an off_by_default plugin

the reason we ask for a "why" is because you're stuck in an XY problem

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

No branches or pull requests

3 participants