8000 MNT: minor improvement to code · matplotlib/matplotlib@949c380 · GitHub
[go: up one dir, main page]

Skip to content

Commit 949c380

Browse files
committed
MNT: minor improvement to code
Use `else` on for loop to be clearer about what break means.
1 parent ad05ed2 commit 949c380

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,21 +573,21 @@ def render_figures(code, code_path, output_dir, output_base, context,
573573
is_doctest, code_pieces = _split_code_at_show(code, function_name)
574574

575575
# Look for single-figure output files first
576-
all_exists = True
577576
img = ImageFile(output_base, output_dir)
578577
for format, dpi in formats:
579578
if context or out_of_date(code_path, img.filename(format),
580579
includes=code_includes):
581580
all_exists = False
582581
break
583582
img.formats.append(format)
583+
else:
584+
all_exists = True
584585

585586
if all_exists:
586587
return [(code, [img])]
587588

588589
# Then look for multi-figure output files
589590
results = []
590-
all_exists = True
591591
for i, code_piece in enumerate(code_pieces):
592592
images = []
593593
for j in itertools.count():
@@ -611,6 +611,8 @@ def render_figures(code, code_path, output_dir, output_base, context,
611611
if not all_exists:
612612
break
613613
results.append((code_piece, images))
614+
else:
615+
all_exists = True
614616

615617
if all_exists:
616618
return results

0 commit comments

Comments
 (0)
0