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

Can we have separate rules for exception builtins? #126

Open
cielavenir opened this issue May 3, 2024 · 1 comment
Open

Can we have separate rules for exception builtins? #126

cielavenir opened this issue May 3, 2024 · 1 comment

Comments

@cielavenir
Copy link
Contributor

The source code

from requests.exceptions import ConnectionError

Raises A004 import statement "ConnectionError" is shadowing a Python builtin.

I understand that ConnectionError is a builtin, which is a subclass of OSError. However, ConnectionError is quite widely used term.

The more issue is, when we apply flake8-builtins in CI, we cannot make a new connection module which provides ConnectionError.

Can we have separate rules for such exception builtins?

/cc @felixvd @hemangandhi @ntohge

@gforcada
Copy link
Owner

Hi @cielavenir! thanks for using flake8-builtins and taking the time to make this report!

You can use the --builtins-ignorelist ConnectionError command line option, or configuration option to ignore builtins that you consider safe to override 👍🏾

Another option would be to change the code to:

from requests import exceptions

...

try:
  ...
except exception.ConnectionError
    ...

I hope this helps! 🍀

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

2 participants