Skip to content

Commit eb21989

Browse files
committed
pyformat again
1 parent f0b0469 commit eb21989

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

tools/tensorflow_docs/tools/nblint/style/gemini_cookbook.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def copyright_check(args):
8484
@lint(
8585
message="Apache license cell is required",
8686
scope=Options.Scope.CODE,
87-
cond=Options.Cond.ANY)
87+
cond=Options.Cond.ANY,
88+
)
8889
def license_check(args):
8990
if license_re.search(args["cell_source"]):
9091
return True
@@ -126,8 +127,10 @@ def get_arg_or_fail(user_args, arg_name, arg_fmt):
126127
return user_args.get(arg_name)
127128
else:
128129
fail(
129-
f"Requires user-argument '{arg_name}': nblint --arg={arg_name}:{arg_fmt} ...",
130-
always_show=True)
130+
f"Requires user-argument '{arg_name}': nblint"
131+
f" --arg={arg_name}:{arg_fmt} ...",
132+
always_show=True,
133+
)
131134

132135

133136
def split_doc_path(filepath):
@@ -157,8 +160,8 @@ def split_doc_path(filepath):
157160
def split_path_on_dir(fp, dirname, offset=1):
158161
parts = fp.parts
159162
idx = parts.index(dirname)
160-
docs_dir = pathlib.Path(*parts[idx:idx + offset])
161-
rel_path = fp.relative_to(*parts[:idx + offset])
163+
docs_dir = pathlib.Path(*parts[idx : idx + offset])
164+
rel_path = fp.relative_to(*parts[: idx + offset])
162165
return docs_dir, rel_path
163166

164167
if "site" in fp_full.parts:
@@ -180,7 +183,8 @@ def split_path_on_dir(fp, dirname, offset=1):
180183
@lint(
181184
message="Missing or malformed URL in Colab button.",
182185
scope=Options.Scope.TEXT,
183-
cond=Options.Cond.ANY)
186+
cond=Options.Cond.ANY,
187+
)
184188
def button_colab(args):
185189
"""Test that the URL in the Colab button matches the file path."""
186190
cell_source = args["cell_source"]
@@ -201,13 +205,15 @@ def button_colab(args):
201205
fail(
202206
f"Colab button URL doesn't match: {this_url}",
203207
fix=fix.regex_between_groups_replace_all,
204-
fix_args=[r"(href.*)http.*?(\\\".*colab_logo_32px.png)", this_url])
208+
fix_args=[r"(href.*)http.*?(\\\".*colab_logo_32px.png)", this_url],
209+
)
205210

206211

207212
@lint(
208213
message="Missing or malformed URL in Download button.",
209214
scope=Options.Scope.TEXT,
210-
cond=Options.Cond.ANY)
215+
cond=Options.Cond.ANY,
216+
)
211217
def button_download(args):
212218
"""Test that the URL in the Download button matches the file path."""
213219
cell_source = args["cell_source"]
@@ -224,21 +230,24 @@ def button_download(args):
224230

225231
this_url = urllib.parse.urljoin(
226232
"https://storage.googleapis.com",
227-
str(f"tensorflow_docs/{repo_name}" / docs_dir / rel_path))
233+
str(f"tensorflow_docs/{repo_name}" / docs_dir / rel_path),
234+
)
228235

229236
if is_button_cell_re.search(cell_source) and cell_source.find(this_url) != -1:
230237
return True
231238
else:
232239
fail(
233240
f"Download button URL doesn't match: {this_url}",
234241
fix=fix.regex_between_groups_replace_all,
235-
fix_args=[r"(href.*)http.*?(\\\".*download_logo_32px.png)", this_url])
242+
fix_args=[r"(href.*)http.*?(\\\".*download_logo_32px.png)", this_url],
243+
)
236244

237245

238246
@lint(
239247
message="Missing or malformed URL in GitHub button.",
240248
scope=Options.Scope.TEXT,
241-
cond=Options.Cond.ANY)
249+
cond=Options.Cond.ANY,
250+
)
242251
def button_github(args):
243252
"""Test that the URL in the GitHub button matches the file path."""
244253
cell_source = args["cell_source"]
@@ -259,13 +268,15 @@ def button_github(args):
259268
fail(
260269
f"GitHub button URL doesn't match: {this_url}",
261270
fix=fix.regex_between_groups_replace_all,
262-
fix_args=[r"(href.*)http.*?(\\\".*GitHub-Mark-32px.png)", this_url])
271+
fix_args=[r"(href.*)http.*?(\\\".*GitHub-Mark-32px.png)", this_url],
272+
)
263273

264274

265275
@lint(
266276
message="Missing or malformed URL in 'View on' button.",
267277
scope=Options.Scope.TEXT,
268-
cond=Options.Cond.ANY)
278+
cond=Options.Cond.ANY,
279+
)
269280
def button_website(args):
270281
"""Test that the website URL in the 'View on' button matches the file path.
271282
@@ -310,7 +321,8 @@ def button_website(args):
310321
@lint(
311322
message="Missing or malformed URL in 'TFHub' button.",
312323
scope=Options.Scope.TEXT,
313-
cond=Options.Cond.ANY)
324+
cond=Options.Cond.ANY,
325+
)
314326
def button_hub(args):
315327
"""Notebooks that mention tfhub.dev should have a TFHub button."""
316328
cell_source = args["cell_source"]
@@ -333,7 +345,8 @@ def button_hub(args):
333345
@lint(
334346
message="Remove extra buttons from TF 1.x docs.",
335347
scope=Options.Scope.TEXT,
336-
cond=Options.Cond.ALL)
348+
cond=Options.Cond.ALL,
349+
)
337350
def button_r1_extra(args):
338351
"""The r1/ docs should not have website or download buttons."""
339352
cell_source = args["cell_source"]
@@ -353,10 +366,13 @@ def button_r1_extra(args):
353366
base_url = "https://www.tensorflow.org/"
354367

355368
# Look for button URLs that shouldn't be there..
356-
if (re.search(f"{base_url}/(?!images)", cell_source) or
357-
cell_source.find(download_url) != -1):
369+
if (
370+
re.search(f"{base_url}/(?!images)", cell_source)
371+
or cell_source.find(download_url) != -1
372+
):
358373
fail(
359-
"Remove the 'View on' and 'Download notebook' buttons since r1/ docs are not published."
374+
"Remove the 'View on' and 'Download notebook' buttons since r1/ docs"
375+
" are not published."
360376
)
361377
else:
362378
return True

0 commit comments

Comments
 (0)