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

Bare/Naked exception catching #62

Open
mpkocher opened this issue Feb 9, 2021 · 1 comment
Open

Bare/Naked exception catching #62

mpkocher opened this issue Feb 9, 2021 · 1 comment

Comments

@mpkocher
Copy link

mpkocher commented Feb 9, 2021

There's a few "naked" or bare exception usage that can yield some difficult to track down bugs.

There's a difference between except: and except Exception. The former is catching SystemExit, KeyboardInterrupt, and GeneratorExit.

https://docs.python.org/3/library/exceptions.html#exception-hierarchy

http://www.wilfred.me.uk/blog/2013/11/03/no-naked-excepts/

Some tooling, such as pylint can help proactively catch some of these potential issues.

$ pylint express | grep -i bare-except
express/parsers/structure.py:92:8: W0702: No exception type(s) specified (bare-except)
express/parsers/structure.py:96:12: W0702: No exception type(s) specified (bare-except)
express/parsers/formats/xml.py:20:12: W0702: No exception type(s) specified (bare-except)
express/parsers/apps/vasp/parser.py:128:8: W0702: No exception type(s) specified (bare-except)
express/parsers/apps/espresso/parser.py:331:12: W0702: No exception type(s) specified (bare-except)
express/properties/material.py:66:8: W0702: No exception type(s) specified (bare-except)
@timurbazhirov
Copy link
Member

Hi Michael - thanks for pointing this out! We'll review and plan to schedule this for inclusion in the near term.

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