From 32de41ed8939dc5a32a7b5d9318141fdc8f3eade Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 3 Nov 2022 07:20:30 +0000 Subject: [PATCH] Update pre-commit hooks and reformat --- .pre-commit-config.yaml | 6 +++++- core/util/django_settings_export.py | 29 ++++++++++------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68d7f35..5517168 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: args: [--max-line-length=88] exclude: ^core/migrations - repo: https://github.com/rtts/djhtml - rev: 'v1.5.2' # replace with the latest tag on GitHub + rev: 'v1.5.2' hooks: - id: djhtml args: [-t 2] @@ -24,6 +24,10 @@ repos: exclude : ^core/static/css # slow - id: djjs exclude: ^core/static/js # slow + - repo: https://github.com/sirwart/ripsecrets.git + rev: v0.1.5 + hooks: + - id: ripsecrets # - repo: https://github.com/thibaudcolas/curlylint # rev: v0.13.1 # hooks: diff --git a/core/util/django_settings_export.py b/core/util/django_settings_export.py index 2649e22..b31fe40 100644 --- a/core/util/django_settings_export.py +++ b/core/util/django_settings_export.py @@ -7,13 +7,10 @@ https://github.com/jakubroztocil/django-settings-export from django.conf import settings as django_settings from django.core.exceptions import ImproperlyConfigured +__version__ = "1.2.1" -__version__ = '1.2.1' - -VARIABLE_NAME = getattr(django_settings, - 'SETTINGS_EXPORT_VARIABLE_NAME', - 'settings') +VARIABLE_NAME = getattr(django_settings, "SETTINGS_EXPORT_VARIABLE_NAME", "settings") class SettingsExportError(ImproperlyConfigured): @@ -35,16 +32,13 @@ def settings_export(request): set, the context variable will be `settings`. """ - variable_name = getattr(django_settings, - 'SETTINGS_EXPORT_VARIABLE_NAME', - 'settings') - return { - variable_name: _get_exported_settings() - } + variable_name = getattr( + django_settings, "SETTINGS_EXPORT_VARIABLE_NAME", "settings" + ) + return {variable_name: _get_exported_settings()} class ExportedSettings(dict): - def __getitem__(self, item): """Fail loudly if accessing a setting that is not exported.""" try: @@ -55,24 +49,21 @@ class ExportedSettings(dict): # can access the existing attribute (e.g. `items()`). raise raise UnexportedSettingError( - 'The `{key}` setting key is not accessible' + "The `{key}` setting key is not accessible" ' from templates: add "{key}" to' - ' `settings.SETTINGS_EXPORT` to change that.' - .format(key=item) + " `settings.SETTINGS_EXPORT` to change that.".format(key=item) ) def _get_exported_settings(): exported_settings = ExportedSettings() - for key in getattr(django_settings, 'SETTINGS_EXPORT', []): + for key in getattr(django_settings, "SETTINGS_EXPORT", []): try: value = getattr(django_settings, key) except AttributeError: raise UndefinedSettingError( '"settings.%s" is included in settings.SETTINGS_EXPORT ' - 'but it does not exist. ' - % key + "but it does not exist. " % key ) exported_settings[key] = value return exported_settings -