Skip to content

Feature: add support for flake8-bugbear#36

Merged
TrueBrain merged 11 commits intoTrueBrain:mainfrom
lt-mayonesa:main
Jun 27, 2021
Merged

Feature: add support for flake8-bugbear#36
TrueBrain merged 11 commits intoTrueBrain:mainfrom
lt-mayonesa:main

Conversation

@lt-mayonesa
Copy link
Copy Markdown
Contributor

Hey!, i just had the need to add PyCQA/flake8-bugbear to one of my projects. Figured it would be nice to support it here directly.

Let me know if you find it useful or would like anything changed.

@TrueBrain
Copy link
Copy Markdown
Owner

Thank you so much for this work, I really appreciate it!

In my mind, I keep ping-ponging between two things, and I am curious about your opinion.

On one hand, I think additions like this are fine, code looks good, so we should do it.

On the other hand, there are many more plugins to flake8 people might want to use. A curated list of them can be found here: https://github.com/DmytroLitvinov/awesome-flake8-extensions .
Adding support for all of those is not going to work. So where to draw the line?

Recently I made possible that you can install any plugin yourself before executing this action, so you can be in control of what plugins you want. But that might not be for everyone.

Additional, bugbear is a bit special, as it is one of the only ones I know of that use their own letter for warning: a B.

So I wonder if we shouldn't be doing the following:

  • Change the "warning" filter to include B too.
  • Add a more generic option, something like: plugins, which contains a list of plugins to install with this action. Syntax can be as simple as plugins: flake8-bugbear or plugins: flake8-bugbear==3.8.0 in case anyone wants to pin the version. And we can easily support multiple plugins: plugins: flake8-bugbear flake8-commas. We can just pass the whole set to pip and let pip deal with installing the right thing :)

This way we don't only add bugbear support, but also support for any of the other plugins. What do you think? Would you be up for making this change?

@lt-mayonesa
Copy link
Copy Markdown
Contributor Author

lt-mayonesa commented Jun 27, 2021

Ah yes, in my head that was the default next step in evolving this action. Giving that you replied fast and is Sunday morning i think i can cook something up :)

Add a more generic option, something like: plugins ....

Yes, i was thinking the same thing.

Change the "warning" filter to include B too.

I just gave the extensions list a quick glance and already found other codes (D for flake8_docstrings, H for cohesion)

The solution in my head would be to also make the pattern.regexp parameterized. ie:

with:
    error_classes: E,F # this would be the default
    warning_classes: W,B,D

or

with:
    errors_pattern: ^([^:]*):(\\d+):(\\d+): ([EF]\\d\\d\\d) (.*)$
    warnings_pattern: ^([^:]*):(\\d+):(\\d+): ([W]\\d\\d\\d) (.*)$

Maybe at some point in time support both?
I'll get started with the first one for now.

edited: changed codes_prefixes to classes which is more correct (https://flake8.pycqa.org/en/latest/glossary.html#term-error-class)

Copy link
Copy Markdown
Owner

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

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

Looking really good :D I like this solution a lot more, really nice.

Some minor feedback, mostly nitpicking :)

@lt-mayonesa
Copy link
Copy Markdown
Contributor Author

Done on my side for now.

The final behavior for classes is as following:

default values: error_classes = E,F / warning_classes = ''

  • error_classes defined & warning_classes undefined: [error_classes] -> [^error_classes]
  • error_classes defined & warning_classes defined: [error_classes] -> [warning_classes]

Let me know if anything else needs to be changed :)

pd: it's my assumption that this PR will be squashed. I can always rebase on my side if necessary

Copy link
Copy Markdown
Owner

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

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

I think this is spot on :D Really nice work, tnx a lot! One minor thing, and a nitpick, but otherwise good to go!

And yes, I will squash, no worries :)

- uses: actions/checkout@v2
- uses: ./
with:
plugins: flake8-bugbear
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think we should set the path here to example_bugbear. Means there are less repeated warnings, and easier for me to check if a PR breaks anything :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ouch, i actually thought of that and then totally forgot. pushing


# Enable the matcher.
ACTION_FOLDER=$(dirname ${0})
echo " - error_classes: $INPUT_ERROR_CLASSES"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

really nitpicking here, sorry: should be ${INPUT_ERROR_CLASSES} :D (similar for the other cases closeby)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Owner

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

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

w00p :D

@TrueBrain TrueBrain merged commit c2deca2 into TrueBrain:main Jun 27, 2021
@TrueBrain
Copy link
Copy Markdown
Owner

v2.1 released with this feature. I am really happy with this, this is a very solid addition to the action :D Tnx again!

@lt-mayonesa
Copy link
Copy Markdown
Contributor Author

No problem! thanks for replying fast :)

It works like a charm
image

pd: in case you were curious https://github.com/redbeestudios/hexagon

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