Skip to content

Commit d29b04e

Browse files
committed
Update pre-commits and re-format the code
also bump version 2.1.5
1 parent 4dff7e7 commit d29b04e

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.1.0
3+
rev: v4.3.0
44
hooks:
55
- id: trailing-whitespace # trims trailing whitespace
66
args: [--markdown-linebreak-ext=md]
@@ -19,7 +19,7 @@ repos:
1919
args: [--target-version, "3.2"]
2020

2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.31.0
22+
rev: v2.37.3
2323
hooks:
2424
- id: pyupgrade
2525

@@ -30,6 +30,6 @@ repos:
3030
name: isort (python)
3131

3232
- repo: https://github.com/psf/black
33-
rev: 22.3.0
33+
rev: 22.6.0
3434
hooks:
3535
- id: black

django_nextjs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
default_app_config = "django_nextjs.apps.NextJSConfig"
22

3-
__version__ = "2.1.4"
3+
__version__ = "2.1.5"

django_nextjs/render.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def _get_nextjs_response_headers(headers):
5757
return {key: headers[key] for key in useful_header_keys if key in headers}
5858

5959

60-
def _render_nextjs_page_to_string_sync(request: HttpRequest, template_name: str = "", context=None, using=None, allow_redirects=False) -> str:
60+
def _render_nextjs_page_to_string_sync(
61+
request: HttpRequest, template_name: str = "", context=None, using=None, allow_redirects=False
62+
) -> str:
6163
page = requests.utils.quote(request.path_info.lstrip("/"))
6264
params = {k: request.GET.getlist(k) for k in request.GET.keys()}
6365

@@ -81,15 +83,27 @@ def _render_nextjs_page_to_string_sync(request: HttpRequest, template_name: str
8183
return html, response.status_code, response_headers
8284

8385

84-
def render_nextjs_page_to_string_sync(request: HttpRequest, template_name: str = "", context=None, using=None, allow_redirects=False) -> str:
85-
html, _, _ = _render_nextjs_page_to_string_sync(request, template_name, context, using=using, allow_redirects=allow_redirects)
86+
def render_nextjs_page_to_string_sync(
87+
request: HttpRequest, template_name: str = "", context=None, using=None, allow_redirects=False
88+
) -> str:
89+
html, _, _ = _render_nextjs_page_to_string_sync(
90+
request, template_name, context, using=using, allow_redirects=allow_redirects
91+
)
8692
return html
8793

8894

8995
def render_nextjs_page_sync(
90-
request: HttpRequest, template_name: str = "", context=None, content_type=None, override_status=None, using=None, allow_redirects=False
96+
request: HttpRequest,
97+
template_name: str = "",
98+
context=None,
99+
content_type=None,
100+
override_status=None,
101+
using=None,
102+
allow_redirects=False,
91103
) -> str:
92-
content, status, headers = _render_nextjs_page_to_string_sync(request, template_name, context, using=using, allow_redirects=allow_redirects)
104+
content, status, headers = _render_nextjs_page_to_string_sync(
105+
request, template_name, context, using=using, allow_redirects=allow_redirects
106+
)
93107
return HttpResponse(content, content_type, status if override_status is None else override_status, headers=headers)
94108

95109

@@ -104,7 +118,9 @@ async def _render_nextjs_page_to_string_async(
104118
cookies=_get_cookies(request),
105119
headers=_get_headers(request),
106120
) as session:
107-
async with session.get(f"{NEXTJS_SERVER_URL}/{page}", params=params, allow_redirects=allow_redirects) as response:
121+
async with session.get(
122+
f"{NEXTJS_SERVER_URL}/{page}", params=params, allow_redirects=allow_redirects
123+
) as response:
108124
html = await response.text()
109125
response_headers = _get_nextjs_response_headers(response.headers)
110126

@@ -121,12 +137,22 @@ async def _render_nextjs_page_to_string_async(
121137
async def render_nextjs_page_to_string_async(
122138
request: HttpRequest, template_name: str = "", context=None, using=None, allow_redirects=False
123139
) -> str:
124-
html, _, _ = await _render_nextjs_page_to_string_async(request, template_name, context, using=using, allow_redirects=allow_redirects)
140+
html, _, _ = await _render_nextjs_page_to_string_async(
141+
request, template_name, context, using=using, allow_redirects=allow_redirects
142+
)
125143
return html
126144

127145

128146
async def render_nextjs_page_async(
129-
request: HttpRequest, template_name: str = "", context=None, content_type=None, override_status=None, using=None, allow_redirects=False
147+
request: HttpRequest,
148+
template_name: str = "",
149+
context=None,
150+
content_type=None,
151+
override_status=None,
152+
using=None,
153+
allow_redirects=False,
130154
) -> str:
131-
content, status, headers = await _render_nextjs_page_to_string_async(request, template_name, context, using=using, allow_redirects=allow_redirects)
155+
content, status, headers = await _render_nextjs_page_to_string_async(
156+
request, template_name, context, using=using, allow_redirects=allow_redirects
157+
)
132158
return HttpResponse(content, content_type, status if override_status is None else override_status, headers=headers)

0 commit comments

Comments
 (0)