monim67 / django-bootstrap-datepicker-plus

Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django >= 2.0
https://pypi.python.org/pypi/django-bootstrap-datepicker-plus
MIT License
223 stars 61 forks source link

PEP8: Avoid bare exceptions #108

Closed cclauss closed 5 months ago

cclauss commented 9 months ago

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 = None

A 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, use except Exception: (bare except is equivalent to except BaseException:).

Approach

How does this change address the problem?

Fix the bare exception as recommended in PEP8.

Blog Posts

monim67 commented 9 months ago

Can you please improve the PR description? I don't understand it.

cclauss commented 9 months ago

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.