Update pre-commit hooks and reformat

master
Mark Veidemanis 1 year ago
parent 1424e34f38
commit 32de41ed89
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -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:

@ -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

Loading…
Cancel
Save