Skip to content

Commit

Permalink
Reformat code with black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed Jan 25, 2022
1 parent fec3909 commit 983ac1c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
5 changes: 1 addition & 4 deletions pattern_library/monkey_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from django.template.library import SimpleNode

from pattern_library.utils import (
is_pattern_library_context,
render_pattern,
)
from pattern_library.utils import is_pattern_library_context, render_pattern

logger = logging.getLogger(__name__)
UNSPECIFIED = object()
Expand Down
5 changes: 2 additions & 3 deletions pattern_library/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.urls import re_path, path
from django.urls import path, re_path

from pattern_library import get_pattern_template_suffix, views

Expand All @@ -19,7 +19,6 @@
views.RenderPatternView.as_view(),
name="render_pattern",
),

# API rendering
path('api/v1/render-pattern', views.render_pattern_api, name='render_pattern_api'),
path("api/v1/render-pattern", views.render_pattern_api, name="render_pattern_api"),
]
6 changes: 3 additions & 3 deletions pattern_library/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ def render_pattern(request, template_name, allow_non_patterns=False, config=None
if not config:
config = get_pattern_config(template_name)

context = config.get('context', {})
tags = config.get('tags', {})
context = config.get("context", {})
tags = config.get("tags", {})
mark_context_strings_safe(context)
context[get_pattern_context_var_name()] = True
context['__pattern_library_tag_overrides'] = tags
context["__pattern_library_tag_overrides"] = tags
for modifier in registry.get_for_template(template_name):
modifier(context=context, request=request)
return render_to_string(template_name, request=request, context=context)
Expand Down
6 changes: 4 additions & 2 deletions pattern_library/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils.html import escape
from django.views.decorators.clickjacking import xframe_options_sameorigin
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.base import TemplateView, View
from django.views.generic.base import TemplateView

from pattern_library import get_base_template_names, get_pattern_base_template_name
from pattern_library.exceptions import PatternLibraryEmpty, TemplateIsNotPattern
Expand Down Expand Up @@ -111,7 +111,9 @@ def render_pattern_api(request):
config = data["config"]

try:
rendered_pattern = render_pattern(request, template_name, allow_non_patterns=False, config=config)
rendered_pattern = render_pattern(
request, template_name, allow_non_patterns=False, config=config
)
except TemplateIsNotPattern:
raise Http404

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_renders_with_tag_overrides(self):
},
},
)
self.assertContains(response, '/hello-api')
self.assertContains(response, "/hello-api")

def test_404(self):
api_endpoint = reverse("pattern_library:render_pattern_api")
Expand Down

0 comments on commit 983ac1c

Please sign in to comment.