Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 158a822

Browse files
authored
Merge pull request #14533 from anntzer/style
MNT: Misc. style fixes.
2 parents b148183 + 86a7dc4 commit 158a822

File tree

7 files changed

+31
-19
lines changed

7 files changed

+31
-19
lines changed

.flake8

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ per-file-ignores =
3030
setup.py: E402
3131
setupext.py: E501
3232

33-
tools/compare_backend_driver_results.py: E501
3433
tools/subset.py: E221, E251, E261, E302, E501
3534

3635
lib/matplotlib/_cm.py: E202, E203, E302
3736
lib/matplotlib/_mathtext_data.py: E203, E261
3837
lib/matplotlib/font_manager.py: E203, E221, E251, E501
3938
lib/matplotlib/mathtext.py: E221, E251
40-
lib/matplotlib/pylab.py: E501
4139
lib/matplotlib/rcsetup.py: E501
4240
lib/matplotlib/tests/test_mathtext.py: E501
4341
lib/matplotlib/transforms.py: E201, E202, E203
@@ -47,10 +45,6 @@ per-file-ignores =
4745
lib/mpl_toolkits/axisartist/angle_helper.py: E221
4846

4947
doc/conf.py: E402, E501
50-
doc/sphinxext/github.py: E302, E501
51-
doc/sphinxext/math_symbol_table.py: E302, E501
52-
doc/sphinxext/skip_deprecated.py: E302
53-
doc/users/generate_credits.py: E302, E501
5448
tutorials/advanced/path_tutorial.py: E402, E501
5549
tutorials/advanced/patheffects_guide.py: E402, E501
5650
tutorials/advanced/transforms_tutorial.py: E402, E501

doc/sphinxext/github.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from docutils import nodes, utils
2121
from docutils.parsers.rst.roles import set_classes
2222

23+
2324
def make_link_node(rawtext, app, type, slug, options):
2425
"""Create a link to a github resource.
2526
@@ -37,7 +38,8 @@ def make_link_node(rawtext, app, type, slug, options):
3738
if not base.endswith('/'):
3839
base += '/'
3940
except AttributeError as err:
40-
raise ValueError('github_project_url configuration value is not set (%s)' % str(err))
41+
raise ValueError(
42+
f'github_project_url configuration value is not set ({err})')
4143

4244
ref = base + type + '/' + slug + '/'
4345
set_classes(options)
@@ -48,6 +50,7 @@ def make_link_node(rawtext, app, type, slug, options):
4850
**options)
4951
return node
5052

53+
5154
def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
5255
"""Link to a GitHub issue.
5356
@@ -88,6 +91,7 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
8891
node = make_link_node(rawtext, app, category, str(issue_num), options)
8992
return [node], []
9093

94+
9195
def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
9296
"""Link to a GitHub user.
9397
@@ -107,7 +111,9 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
107111
node = nodes.reference(rawtext, text, refuri=ref, **options)
108112
return [node], []
109113

110-
def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
114+
115+
def ghcommit_role(
116+
name, rawtext, text, lineno, inliner, options={}, content=[]):
111117
"""Link to a GitHub commit.
112118
113119
Returns 2 part tuple containing list of nodes to insert into the
@@ -130,7 +136,8 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
130136
if not base.endswith('/'):
131137
base += '/'
132138
except AttributeError as err:
133-
raise ValueError('github_project_url configuration value is not set (%s)' % str(err))
139+
raise ValueError(
140+
f'github_project_url configuration value is not set ({err})')
134141

135142
ref = base + text
136143
node = nodes.reference(rawtext, text[:6], refuri=ref, **options)

doc/sphinxext/math_symbol_table.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
\iiint \iint \oiiint"""]
9797
]
9898

99+
99100
def run(state_machine):
100101
def get_n(n, l):
101102
part = []
@@ -135,10 +136,13 @@ def get_n(n, l):
135136
state_machine.insert_input(lines, "Symbol table")
136137
return []
137138

138-
def math_symbol_table_directive(name, arguments, options, content, lineno,
139-
content_offset, block_text, state, state_machine):
139+
140+
def math_symbol_table_directive(
141+
name, arguments, options, content, lineno,
142+
content_offset, block_text, state, state_machine):
140143
return run(state_machine)
141144

145+
142146
def setup(app):
143147
app.add_directive(
144148
'math_symbol_table', math_symbol_table_directive,
@@ -147,6 +151,7 @@ def setup(app):
147151
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
148152
return metadata
149153

154+
150155
if __name__ == "__main__":
151156
# Do some verification of the tables
152157
from matplotlib import _mathtext_data

doc/sphinxext/skip_deprecated.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Skip deprecated members
22

3+
34
def skip_deprecated(app, what, name, obj, skip, options):
45
if skip:
56
return skip
@@ -8,6 +9,7 @@ def skip_deprecated(app, what, name, obj, skip, options):
89
if skip_list is not None:
910
return getattr(obj, "__name__", None) in skip_list
1011

12+
1113
def setup(app):
1214
app.connect('autodoc-skip-member', skip_deprecated)
1315

doc/users/generate_credits.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
development and usefulness.
6060
"""
6161

62+
6263
def check_duplicates():
6364
text = subprocess.check_output(['git', 'shortlog', '--summary', '--email'])
6465
lines = text.decode('utf8').split('\n')
@@ -71,7 +72,8 @@ def check_duplicates():
7172
'more than one name.\nConsider adding them to .mailmap.\n')
7273
for email, count in email_counter.items():
7374
if count > 1:
74-
print('%s\n%s' % (email, '\n'.join(l for l in lines if email in l)))
75+
print('{}\n{}'.format(
76+
email, '\n'.join(l for l in lines if email in l)))
7577

7678

7779
def generate_credits():

lib/matplotlib/pylab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
stem - make a stem plot
8585
subplot - make one subplot (numrows, numcols, axesnum)
8686
subplots - make a figure with a set of (numrows, numcols) subplots
87-
subplots_adjust - change the params controlling the subplot positions of current figure
87+
subplots_adjust - control the subplot positions of current figure
8888
subplot_tool - launch the subplot configuration tool
8989
suptitle - add a figure title
9090
table - add a table to the plot

tools/compare_backend_driver_results.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def compare_results(results_a, results_b):
3434
sections = results_a.keys()
3535
sections.sort()
3636
for section in results_a.keys():
37-
print("backend %s" % section)
38-
print(" %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff"))
37+
print(f"backend {section}" % section)
38+
print(f" {'test':40} {'a':>6} {'b':>6} {'delta':>6} {'% diff':>6}")
3939
print(" " + '-' * 69)
4040
deltas = []
4141
section_a = results_a[section]
@@ -46,7 +46,8 @@ def compare_results(results_a, results_b):
4646
else:
4747
time_a = section_a[test]
4848
time_b = section_b[test]
49-
deltas.append([time_b / time_a, time_b - time_a, time_a, time_b, test])
49+
deltas.append(
50+
[time_b / time_a, time_b - time_a, time_a, time_b, test])
5051
for test in section_b.keys():
5152
if test not in section_a:
5253
deltas.append([None, None, None, section_b[test], test])
@@ -55,11 +56,12 @@ def compare_results(results_a, results_b):
5556
for diff, delta, time_a, time_b, test in deltas:
5657
if diff is None:
5758
if time_a is None:
58-
print(" %-40s ??? % 6.3f ??? ???" % (test, time_b))
59+
print(f" {test:40} ??? {time_b: 6.3f} ??? ???")
5960
else:
60-
print(" %-40s % 6.3f ??? ??? ???" % (test, time_a))
61+
print(f" {test:40} {time_a: 6.3f} ??? ??? ???")
6162
else:
62-
print(" %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100))
63+
print(f" {test:40} {time_a: 6.3f} {time_b: 6.3f} "
64+
f"{delta: 6.3f} {diff:6.0%}")
6365

6466

6567
if __name__ == '__main__':

0 commit comments

Comments
 (0)