Using the pass statement in an exception block ignores the exception. Exceptions should never be ignored. Instead, the user must add code to notify an exception occurred and attempt to handle it or recover from it.
Non-Compliant Code Examples
a=2b=0try:c=a/bexceptExceptionase:pass# should use a regular statement and not ignore the exception
Compliant Code Examples
a=2b=0try:c=a/bexceptValueErrorase:print(e)passtry:do_iteration()exceptStopIteration:# this is okaypass
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- python-best-practices # Rules to enforce Python best practices.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines