django-bootstrap-datepicker-plus
django-bootstrap-datepicker-plus copied to clipboard
PEP8: Avoid bare exceptions
- https://realpython.com/the-most-diabolical-python-antipattern
- https://docs.astral.sh/ruff/rules/bare-except
PR Description
Purpose
We have a bare exception.
From PEP8:
When catching exceptions, mention specific exceptions whenever possible instead of using a bare
except:clause:try: import platform_specific_module except ImportError: platform_specific_module = NoneA bare
except:clause will catch SystemExit and KeyboardInterrupt exceptions, making it harder to interrupt a program with Control-C, and can disguise other problems. If you want to catch all exceptions that signal program errors, useexcept Exception:(bare except is equivalent toexcept BaseException:).
Approach
How does this change address the problem?
Fix the bare exception as recommended in PEP8.
Blog Posts
- How to Pull Request Github Repo with Learning focused Pull Request Template.
Can you please improve the PR description? I don't understand it.
The title says that PEP8 encourages developers to avoid bare exceptions. The first line of the commit body is a link to an article explains why bare exceptions are really bad The second line is a link to the ruff lint rule which explains what bare exceptions are. The Why is this bad? explains why the proposed change is a good idea.