flake8-builtins icon indicating copy to clipboard operation
flake8-builtins copied to clipboard

Add option to ignore certain builtins

Open 0xallie opened this issue 3 years ago • 4 comments

flake8-builtins complains about variables named license, which honestly I don't understand why it even exists outside of the REPL. I don't want to rename them to lic, licence, licence_ or similar, so it would be nice to not have to sprinkle my code with # noqa everywhere.

0xallie avatar Feb 20 '22 13:02 0xallie

Hi @nyuszika7h thanks for using flake8-builtins and taking the time to report about it! ✨

Might it be fixed if eventually #73 is implemented? 🤔 reopen if you think otherwise.

gforcada avatar Feb 23 '22 00:02 gforcada

No, that's the opposite of what I want. That issue suggests adding an option to recognize more identifiers as builtins, but I want it to ignore one that's technically a builtin but basically never used.

(Yes, I could see how it could lead to issues if I forget to define the variable and accidentally use the builtin instead and flake8 doesn't yell at me that it's undefined, but mypy should take care of that.)

0xallie avatar Feb 25 '22 22:02 0xallie

Oh right, sorry, I probably did not read your message properly 🙋🏾 sorry! 🙇🏾

gforcada avatar Mar 01 '22 13:03 gforcada

I noticed credits is already ignored, so maybe license could be just added similarly. But I wouldn't mind it being an option either.

0xallie avatar Aug 28 '22 10:08 0xallie

Upon further investigation, I realized that credits and license are both part of the site module, and are not defined when using python -S. So this reinforces that it might be reasonable to add it to the default ignore list, or at least add an ignore_site option.

Nobody should be using those in scripts anyway (though some people may misuse exit() instead of sys.exit()), so the only potential concern is not being warned about accidentally using the site definition instead of your own if you made a typo, though that can probably be handled by another plugin.

0xallie avatar Oct 01 '22 18:10 0xallie

Yes, that's what I really wanted to do at some point, fortunately @gsingh93 did the heavy work on #80 and I did the extra work on #86 to get it merged 😄

gforcada avatar Oct 08 '22 14:10 gforcada

@nyuszika7h sorry to bother again, I see that what you were asking is to have license and credits ignored by default, with the changes on #85 and #86 you would be able to at least ignore them on the command line when calling flake8, would that be at least a mid term solution?

I'm afraid that saying yes to ignore credits and license will open the can of worms to others saying, that if it was done once, it could also be done also for X and Y 😓

gforcada avatar Oct 08 '22 14:10 gforcada

Having it be configurable is enough for me, I was only suggesting a potential default ignore for all site modules because credits was already on the default ignore list.

0xallie avatar Oct 08 '22 14:10 0xallie