Giter Site home page Giter Site logo

Comments (5)

153957 avatar 153957 commented on June 30, 2024

@ambv

from flake8-bugbear.

ambv avatar ambv commented on June 30, 2024

I changed handling of it to require explicit selection because "enable-extension" doesn't work as expected.

Note that with 16.12.1 you don't have to "enable-extensions" at all. It's enough for you to ignore=E501 for all optional warnings (including the ones from pycodestyle) to be turned on implicitly. This is misleading and exactly why I did something custom here.

The enable-extensions= line did nothing for you all along.

from flake8-bugbear.

153957 avatar 153957 commented on June 30, 2024

Ok, so you no longer enable the B9* checks when ignore=E501 is used, understandable, I also find using ignore to enable the optional rules strange behaviour..
So understandable you require the user to explicitly chose the rules, but is that not exactly what enable-extensions is for? Or do not have access to the list of enabled extensions?
Forcing explicit selection of ALL (i.e. normally default) rules just to use some B9 rules seems strange.

from flake8-bugbear.

ambv avatar ambv commented on June 30, 2024

I haven't really looked too long for why enabled extensions don't work. I'd accept a pull request with a fix.

from flake8-bugbear.

matthijskooijman avatar matthijskooijman commented on June 30, 2024

I'm also running into this. I have a lot of flake8 plugins that implicitly enable a bunch of different codes, all of which get lost when I specify an explicit select in my config (unless I duplicate the list, but I do not really care much for that).

Looking at the code, it seems that enabled-extensions causes the plugin manager to enable these plugins: https://github.com/PyCQA/flake8/blob/52210149474a876c06922ae2c296445af5bdb108/src/flake8/plugins/manager.py#L214-L215

Enabling a plugin, causes its "name" (which is really a prefix for codes) to be added to the extended select list (which causes the code to be implicitly selected). https://github.com/PyCQA/flake8/blob/52210149474a876c06922ae2c296445af5bdb108/src/flake8/plugins/manager.py#L188-L191

The "name" for bugbear is "B":

'B = bugbear:BugBearChecker',

AFAICS, the bugbear plugin is enabled by default, so enable_extensions is essentially a no-op.

One way to fix this would be to let bugbear specify multiple entrypoints: One for B0 and one for B3, both of which are enabled by default (like now), and one for B9 which is disabled by default: https://github.com/PyCQA/flake8/blob/52210149474a876c06922ae2c296445af5bdb108/src/flake8/plugins/manager.py#L516-L517

AFAICS only one of these three plugins actually has to do work, the others can be empty and just serve to prefill the list of included codes. If you do this, you can use enable_extensions to enable the B9 plugin, without having to specify select.

However, I'm not exactly sure that this is really reliable, since I'm not sure if this empty plugin approach is really future-proof (or that it works at all...).

In the end, I suspect this is really something that flake8 might need to solve, except that its select/ignore handling seems quite complex already, as well as its plugin handling (probably because it supports pep8 and pyflakes plugins as well, dunno).

from flake8-bugbear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.