diff --git a/credentials/apps/api/v2/decorators.py b/credentials/apps/api/v2/decorators.py index 54bab4e39..b39e650d4 100644 --- a/credentials/apps/api/v2/decorators.py +++ b/credentials/apps/api/v2/decorators.py @@ -28,7 +28,7 @@ def wrapper(*args, **kwargs): f"[{request.user.username}] originating from [{request.headers.get('host', 'Unknown')}] " f"with data: [{data}]" ) - except Exception as exc: + except Exception as exc: # pylint: disable=broad-exception-caught # catch overly broad exception to try to ensure if logging doesn't work the request will still be # processed logger.error(f"Error logging incoming request: {exc}. Continuing...") diff --git a/credentials/apps/api/v2/views.py b/credentials/apps/api/v2/views.py index 00b0de9c4..da7ce1f89 100644 --- a/credentials/apps/api/v2/views.py +++ b/credentials/apps/api/v2/views.py @@ -266,7 +266,7 @@ def _replace_username_for_all_models(self, current_username, new_username, repla num_rows_changed += model.objects.filter(**{column: current_username}).update( **{column: new_username} ) - except Exception as exc: + except Exception as exc: # pylint: disable=broad-exception-caught log.exception( "Unable to change username from %s to %s. Failed on table %s because %s", current_username, diff --git a/credentials/apps/badges/credly/api_client.py b/credentials/apps/badges/credly/api_client.py index b35eddc7d..72ca64058 100644 --- a/credentials/apps/badges/credly/api_client.py +++ b/credentials/apps/badges/credly/api_client.py @@ -4,7 +4,7 @@ from functools import lru_cache from urllib.parse import urljoin -import requests # pylint: disable=unused-import +import requests from attrs import asdict from django.conf import settings from django.contrib.sites.models import Site diff --git a/credentials/apps/core/api.py b/credentials/apps/core/api.py index b13e4548b..fb918482d 100644 --- a/credentials/apps/core/api.py +++ b/credentials/apps/core/api.py @@ -49,7 +49,7 @@ def get_or_create_user_from_event_data(user_data): # create the user if they don't exist, this follows similar behavior that our JWT authentication implements if # a user doesn't exist when we're making network calls across services user, created = User.objects.get_or_create(username=user_data.pii.username) - except Exception: + except Exception: # pylint: disable=broad-exception-caught logger.exception("Error occurred retrieving or creating a user") return None, None diff --git a/credentials/apps/credentials/api.py b/credentials/apps/credentials/api.py index b8e24028c..c01b79fb8 100644 --- a/credentials/apps/credentials/api.py +++ b/credentials/apps/credentials/api.py @@ -70,7 +70,7 @@ def _update_or_create_credential(username, credential_type, credential_id, statu credential_id=credential_id, defaults={"status": status}, ) - except Exception: + except Exception: # pylint: disable=broad-exception-caught logger.exception( f"Error occurred processing a credential with credential_id [{credential_id}] for user [{username}]" ) @@ -128,7 +128,7 @@ def create_course_cert_config(course_run: "CourseRun", site: "Site", mode: str): course_cert_config = _CourseCertificate.objects.create( course_id=course_run.key, course_run=course_run, site=site, is_active=True, certificate_type=mode ) - except Exception: + except Exception: # pylint: disable=broad-exception-caught logger.exception(f"Error occurred creating a CourseCertificate configuration for course run [{course_run.key}]") return course_cert_config diff --git a/credentials/apps/credentials/utils.py b/credentials/apps/credentials/utils.py index ca2e25292..6bfe050b4 100644 --- a/credentials/apps/credentials/utils.py +++ b/credentials/apps/credentials/utils.py @@ -257,7 +257,7 @@ def send_program_certificate_created_message( ace.send(msg) # We wouldn't want any issues that arise from formatting or sending this email message to interrupt the process # of issuing a learner their Program Certificate. We cast a wide net for exceptions here for this reason. - except Exception as ex: + except Exception as ex: # pylint: disable=broad-exception-caught log.exception( f"Unable to send email to learner with id: [{user.id}] for Program [{program_uuid}]. " f"Error occurred while attempting to format or send message: {ex}" diff --git a/pylintrc b/pylintrc index 2d2a93646..5361015eb 100644 --- a/pylintrc +++ b/pylintrc @@ -64,7 +64,7 @@ # SERIOUSLY. # # ------------------------------ -# Generated by edx-lint version: 5.3.0 +# Generated by edx-lint version: 5.6.0 # ------------------------------ [MASTER] ignore = ,migrations, settings, wsgi.py @@ -259,6 +259,7 @@ enable = useless-suppression, disable = bad-indentation, + broad-exception-raised, consider-using-f-string, duplicate-code, file-ignored, @@ -380,6 +381,6 @@ ext-import-graph = int-import-graph = [EXCEPTIONS] -overgeneral-exceptions = Exception +overgeneral-exceptions = builtins.Exception -# c5ae18c461392d4da971ec11c4c38c26ac0da3e6 +# f359d03cbb0162487655c0e4b6b09dd53da81787