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

Skip to content

Commit 6af009c

Browse files
committed
MNT: minor improvement to code
Use `else` on for loop to be clearer about what break means.
1 parent 4030ff4 commit 6af009c

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
@@ -579,21 +579,21 @@ def render_figures(code, code_path, output_dir, output_base, context,
579579
is_doctest, code_pieces = _split_code_at_show(code, function_name)
580580

581581
# Look for single-figure output files first
582-
all_exists = True
583582
img = ImageFile(output_base, output_dir)
584583
for format, dpi in formats:
585584
if context or out_of_date(code_path, img.filename(format),
586585
includes=code_includes):
587586
all_exists = False
588587
break
589588
img.formats.append(format)
589+
else:
590+
all_exists = True
590591

591592
if all_exists:
592593
return [(code, [img])]
593594

594595
# Then look for multi-figure output files
595596
results = []
596-
all_exists = True
597597
for i, code_piece in enumerate(code_pieces):
598598
images = []
599599
for j in itertools.count():
@@ -617,6 +617,8 @@ def render_figures(code, code_path, output_dir, output_base, context,
617617
if not all_exists:
618618
break
619619
results.append((code_piece, images))
620+
else:
621+
all_exists = True
620622

621623
if all_exists:
622624
return results

0 commit comments

Comments
 (0)
0