From a2ee45ea2df85dbf2e2e1e4f998806ef445387c0 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Mon, 6 Oct 2025 23:28:40 +0200 Subject: [PATCH] chore(backend): fix missing ignore (#10512) * fix ignore * ignore sentry that is not used in prod --- src/backend/InvenTree/InvenTree/sentry.py | 6 +++--- src/backend/InvenTree/InvenTree/settings.py | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/sentry.py b/src/backend/InvenTree/InvenTree/sentry.py index 714b5292c9..5307220ee9 100644 --- a/src/backend/InvenTree/InvenTree/sentry.py +++ b/src/backend/InvenTree/InvenTree/sentry.py @@ -23,7 +23,7 @@ def default_sentry_dsn(): return 'https://3928ccdba1d34895abde28031fd00100@o378676.ingest.sentry.io/6494600' -def sentry_ignore_errors(): +def sentry_ignore_errors(): # pragma: no cover """Return a list of error types to ignore. These error types will *not* be reported to sentry.io. @@ -40,7 +40,7 @@ def sentry_ignore_errors(): ] -def init_sentry(dsn, sample_rate, tags): +def init_sentry(dsn, sample_rate, tags): # pragma: no cover """Initialize sentry.io error reporting.""" logger.info('Initializing sentry.io integration') @@ -66,7 +66,7 @@ def init_sentry(dsn, sample_rate, tags): sentry_sdk.set_tag('git_date', InvenTree.version.inventreeCommitDate()) -def report_exception(exc, scope: Optional[dict] = None): +def report_exception(exc, scope: Optional[dict] = None): # pragma: no cover """Report an exception to sentry.io.""" assert settings.TESTING == False, ( 'report_exception should not be called in testing mode' diff --git a/src/backend/InvenTree/InvenTree/settings.py b/src/backend/InvenTree/InvenTree/settings.py index b06286562c..965fbc05de 100644 --- a/src/backend/InvenTree/InvenTree/settings.py +++ b/src/backend/InvenTree/InvenTree/settings.py @@ -170,7 +170,7 @@ structlog.configure( cache_logger_on_first_use=True, ) # Optionally add database-level logging -if get_setting('INVENTREE_DB_LOGGING', 'db_logging', False): +if get_setting('INVENTREE_DB_LOGGING', 'db_logging', False): # pragma: no cover LOGGING['loggers'] = {'django.db.backends': {'level': LOG_LEVEL or 'DEBUG'}} # Get a logger instance for this setup file @@ -369,7 +369,7 @@ MIDDLEWARE = CONFIG.get( # In DEBUG mode, add support for django-querycount # Ref: https://github.com/bradmontgomery/django-querycount -if DEBUG and get_boolean_setting( +if DEBUG and get_boolean_setting( # pragma: no cover 'INVENTREE_DEBUG_QUERYCOUNT', 'debug_querycount', False ): MIDDLEWARE.append('querycount.middleware.QueryCountMiddleware') @@ -405,7 +405,7 @@ AUTHENTICATION_BACKENDS = ( # LDAP support LDAP_AUTH = get_boolean_setting('INVENTREE_LDAP_ENABLED', 'ldap.enabled', False) -if LDAP_AUTH: +if LDAP_AUTH: # pragma: no cover import django_auth_ldap.config # type: ignore[unresolved-import] import ldap # type: ignore[unresolved-import] @@ -943,7 +943,7 @@ Q_CLUSTER = { } # Configure django-q sentry integration -if SENTRY_ENABLED and SENTRY_DSN: +if SENTRY_ENABLED and SENTRY_DSN: # pragma: no cover Q_CLUSTER['error_reporter'] = {'sentry': {'dsn': SENTRY_DSN}} if GLOBAL_CACHE_ENABLED: # pragma: no cover @@ -1296,14 +1296,14 @@ FRONTEND_SETTINGS = config.get_frontend_settings(debug=DEBUG) FRONTEND_URL_BASE = FRONTEND_SETTINGS['base_url'] # region auth -for app in SOCIAL_BACKENDS: +for app in SOCIAL_BACKENDS: # pragma: no cover # Ensure that the app starts with 'allauth.socialaccount.providers' social_prefix = 'allauth.socialaccount.providers.' - if not app.startswith(social_prefix): # pragma: no cover + if not app.startswith(social_prefix): app = social_prefix + app - INSTALLED_APPS.append(app) # pragma: no cover + INSTALLED_APPS.append(app) SOCIALACCOUNT_PROVIDERS = get_setting( 'INVENTREE_SOCIAL_PROVIDERS', 'social_providers', None, typecast=dict @@ -1331,7 +1331,7 @@ login_attempts = get_setting('INVENTREE_LOGIN_ATTEMPTS', 'login_attempts', 5) try: login_attempts = int(login_attempts) login_attempts = f'{login_attempts}/m,{login_attempts}/m' -except ValueError: +except ValueError: # pragma: no cover pass ACCOUNT_RATE_LIMITS = {'login_failed': login_attempts} @@ -1493,7 +1493,7 @@ FLAGS = { # Get custom flags from environment/yaml CUSTOM_FLAGS = get_setting('INVENTREE_FLAGS', 'flags', None, typecast=dict) -if CUSTOM_FLAGS: +if CUSTOM_FLAGS: # pragma: no cover if not isinstance(CUSTOM_FLAGS, dict): logger.error('Invalid custom flags, must be valid dict: %s', str(CUSTOM_FLAGS)) else: @@ -1552,5 +1552,5 @@ OAUTH2_CHECK_EXCLUDED = [ # This setting mutes schema checks for these rule/met '/api/webhook/{endpoint}/:post', ] -if SITE_URL and not TESTING: +if SITE_URL and not TESTING: # pragma: no cover SPECTACULAR_SETTINGS['SERVERS'] = [{'url': SITE_URL}]