Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52e04f5

Browse filesBrowse files
authored
Merge pull request #17145 from brunobeltran/flake8-docstrings-select
CI: run pydocstyle with our custom options
2 parents 53faed9 + f1b8705 commit 52e04f5
Copy full SHA for 52e04f5

File tree

21 files changed

+73
-62
lines changed
Filter options

21 files changed

+73
-62
lines changed

‎.flake8

Copy file name to clipboardExpand all lines: .flake8
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
[flake8]
22
max-line-length = 79
3+
select =
4+
# flake8 default
5+
C90, E, F, W,
6+
# docstring-convention=numpy
7+
D100, D101, D102, D103, D104, D105, D106,
8+
D200, D201, D202, D204, D205, D206, D207, D208,
9+
D209, D210, D211, D214, D215,
10+
D300, D301, D302,
11+
D400, D401, D403, D404, D405, D406, D407, D408,
12+
D409, D410, D411, D412, D414,
13+
# matplotlib-specific extra pydocstyle errors
14+
D213,
315
ignore =
4-
# Normal default
16+
# flake8 default
517
E121,E123,E126,E226,E24,E704,W503,W504,
618
# Additional ignores:
719
E122, E127, E131,
@@ -14,8 +26,8 @@ ignore =
1426
# pydocstyle
1527
D100, D101, D102, D103, D104, D105, D106, D107,
1628
D200, D202, D203, D204, D205, D207, D212,
17-
D301
18-
D400, D401, D402, D403, D413,
29+
D301,
30+
D400, D401, D402, D403, D404, D413,
1931

2032
exclude =
2133
.git

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ script:
192192
fi
193193
- |
194194
if [[ $RUN_FLAKE8 == 1 ]]; then
195-
flake8 --statistics && echo "Flake8 passed without any issues!"
195+
flake8 --docstring-convention=all --statistics && echo "Flake8 passed without any issues!"
196196
fi
197197
198198
before_cache: |

‎doc/sphinxext/github.py

Copy file name to clipboardExpand all lines: doc/sphinxext/github.py
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Define text roles for GitHub
1+
"""
2+
Define text roles for GitHub.
23
34
* ghissue - Issue
45
* ghpull - Pull Request
@@ -22,7 +23,8 @@
2223

2324

2425
def make_link_node(rawtext, app, type, slug, options):
25-
"""Create a link to a github resource.
26+
"""
27+
Create a link to a github resource.
2628
2729
:param rawtext: Text being replaced with link node.
2830
:param app: Sphinx application context
@@ -53,7 +55,8 @@ def make_link_node(rawtext, app, type, slug, options):
5355

5456

5557
def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
56-
"""Link to a GitHub issue.
58+
"""
59+
Link to a GitHub issue.
5760
5861
Returns 2 part tuple containing list of nodes to insert into the
5962
document and a list of system messages. Both are allowed to be
@@ -94,7 +97,8 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
9497

9598

9699
def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
97-
"""Link to a GitHub user.
100+
"""
101+
Link to a GitHub user.
98102
99103
Returns 2 part tuple containing list of nodes to insert into the
100104
document and a list of system messages. Both are allowed to be
@@ -115,7 +119,8 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
115119

116120
def ghcommit_role(
117121
name, rawtext, text, lineno, inliner, options={}, content=[]):
118-
"""Link to a GitHub commit.
122+
"""
123+
Link to a GitHub commit.
119124
120125
Returns 2 part tuple containing list of nodes to insert into the
121126
document and a list of system messages. Both are allowed to be
@@ -147,7 +152,8 @@ def ghcommit_role(
147152

148153

149154
def setup(app):
150-
"""Install the plugin.
155+
"""
156+
Install the plugin.
151157
152158
:param app: Sphinx application context.
153159
"""

‎examples/axisartist/demo_floating_axis.py

Copy file name to clipboardExpand all lines: examples/axisartist/demo_floating_axis.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020

2121
def curvelinear_test2(fig):
22-
"""Polar projection, but in a rectangular box.
23-
"""
22+
"""Polar projection, but in a rectangular box."""
2423
# see demo_curvelinear_grid.py for details
2524
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform()
2625

‎examples/specialty_plots/radar_chart.py

Copy file name to clipboardExpand all lines: examples/specialty_plots/radar_chart.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727

2828
def radar_factory(num_vars, frame='circle'):
29-
"""Create a radar chart with `num_vars` axes.
29+
"""
30+
Create a radar chart with `num_vars` axes.
3031
3132
This function creates a RadarAxes projection and registers it.
3233

‎examples/statistics/confidence_ellipse.py

Copy file name to clipboardExpand all lines: examples/statistics/confidence_ellipse.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ def confidence_ellipse(x, y, ax, n_std=3.0, facecolor='none', **kwargs):
5353
n_std : float
5454
The number of standard deviations to determine the ellipse's radiuses.
5555
56+
**kwargs
57+
Forwarded to `~matplotlib.patches.Ellipse`
58+
5659
Returns
5760
-------
5861
matplotlib.patches.Ellipse
59-
60-
Other parameters
61-
----------------
62-
kwargs : `~matplotlib.patches.Patch` properties
6362
"""
6463
if x.size != y.size:
6564
raise ValueError("x and y must be the same size")

‎examples/style_sheets/style_sheets_reference.py

Copy file name to clipboardExpand all lines: examples/style_sheets/style_sheets_reference.py
+8-13Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818

1919
def plot_scatter(ax, prng, nb_samples=100):
20-
"""Scatter plot.
21-
"""
20+
"""Scatter plot."""
2221
for mu, sigma, marker in [(-.5, 0.75, 'o'), (0.75, 1., 's')]:
2322
x, y = prng.normal(loc=mu, scale=sigma, size=(2, nb_samples))
2423
ax.plot(x, y, ls='none', marker=marker)
@@ -28,8 +27,7 @@ def plot_scatter(ax, prng, nb_samples=100):
2827

2928

3029
def plot_colored_sinusoidal_lines(ax):
31-
"""Plot sinusoidal lines with colors following the style color cycle.
32-
"""
30+
"""Plot sinusoidal lines with colors following the style color cycle."""
3331
L = 2 * np.pi
3432
x = np.linspace(0, L)
3533
nb_colors = len(plt.rcParams['axes.prop_cycle'])
@@ -41,8 +39,7 @@ def plot_colored_sinusoidal_lines(ax):
4139

4240

4341
def plot_bar_graphs(ax, prng, min_value=5, max_value=25, nb_samples=5):
44-
"""Plot two bar graphs side by side, with letters as x-tick labels.
45-
"""
42+
"""Plot two bar graphs side by side, with letters as x-tick labels."""
4643
x = np.arange(nb_samples)
4744
ya, yb = prng.randint(min_value, max_value, size=(2, nb_samples))
4845
width = 0.25
@@ -54,7 +51,8 @@ def plot_bar_graphs(ax, prng, min_value=5, max_value=25, nb_samples=5):
5451

5552

5653
def plot_colored_circles(ax, prng, nb_samples=15):
57-
"""Plot circle patches.
54+
"""
55+
Plot circle patches.
5856
5957
NB: draws a fixed amount of samples, rather than using the length of
6058
the color cycle, because different styles may have different numbers
@@ -72,8 +70,7 @@ def plot_colored_circles(ax, prng, nb_samples=15):
7270

7371

7472
def plot_image_and_patch(ax, prng, size=(20, 20)):
75-
"""Plot an image with random values and superimpose a circular patch.
76-
"""
73+
"""Plot an image with random values and superimpose a circular patch."""
7774
values = prng.random_sample(size=size)
7875
ax.imshow(values, interpolation='none')
7976
c = plt.Circle((5, 5), radius=5, label='patch')
@@ -84,8 +81,7 @@ def plot_image_and_patch(ax, prng, size=(20, 20)):
8481

8582

8683
def plot_histograms(ax, prng, nb_samples=10000):
87-
"""Plot 4 histograms and a text annotation.
88-
"""
84+
"""Plot 4 histograms and a text annotation."""
8985
params = ((10, 10), (4, 12), (50, 12), (6, 55))
9086
for a, b in params:
9187
values = prng.beta(a, b, size=nb_samples)
@@ -104,8 +100,7 @@ def plot_histograms(ax, prng, nb_samples=10000):
104100

105101

106102
def plot_figure(style_label=""):
107-
"""Setup and plot the demonstration figure with a given style.
108-
"""
103+
"""Setup and plot the demonstration figure with a given style."""
109104
# Use a dedicated RandomState instance to draw the same "random" values
110105
# across the different figures.
111106
prng = np.random.RandomState(96917002)

‎examples/text_labels_and_annotations/arrow_demo.py

Copy file name to clipboardExpand all lines: examples/text_labels_and_annotations/arrow_demo.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def make_arrow_plot(data, size=4, display='length', shape='right',
2929
head_starts_at_zero=True,
3030
rate_labels=lettered_bases_to_rates,
3131
**kwargs):
32-
"""Makes an arrow plot.
32+
"""
33+
Makes an arrow plot.
3334
3435
Parameters
3536
----------

‎examples/text_labels_and_annotations/demo_annotation_box.py

Copy file name to clipboardExpand all lines: examples/text_labels_and_annotations/demo_annotation_box.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""===================
1+
"""
2+
===================
23
Demo Annotation Box
34
===================
45

‎examples/widgets/lasso_selector_demo_sgskip.py

Copy file name to clipboardExpand all lines: examples/widgets/lasso_selector_demo_sgskip.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919

2020
class SelectFromCollection:
21-
"""Select indices from a matplotlib collection using `LassoSelector`.
21+
"""
22+
Select indices from a matplotlib collection using `LassoSelector`.
2223
2324
Selected indices are saved in the `ind` attribute. This tool fades out the
2425
points that are not part of the selection (i.e., reduces their alpha

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ def _call_fc_list():
275275

276276

277277
def get_fontconfig_fonts(fontext='ttf'):
278-
"""List the font filenames known to `fc-list` having the given extension.
279-
"""
278+
"""List font filenames known to `fc-list` having the given extension."""
280279
fontext = ['.' + ext for ext in get_fontext_synonyms(fontext)]
281280
return [fname for fname in _call_fc_list()
282281
if Path(fname).suffix.lower() in fontext]

‎lib/matplotlib/testing/disable_internet.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/disable_internet.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ def turn_on_internet(verbose=False):
135135

136136
@contextlib.contextmanager
137137
def no_internet(verbose=False):
138-
"""Context manager to temporarily disable internet access (if not already
139-
disabled). If it was already disabled before entering the context manager
138+
"""
139+
Temporarily disables internet access (if not already disabled).
140+
141+
If it was already disabled before entering the context manager
140142
(i.e. `turn_off_internet` was called previously) then this is a no-op and
141143
leaves internet access disabled until a manual call to `turn_on_internet`.
142144
"""

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,8 +3791,7 @@ def test_eventplot_defaults():
37913791
('red', (0, 1, 0), None, (1, 0, 1, 0.5)), # a tricky case mixing types
37923792
])
37933793
def test_eventplot_colors(colors):
3794-
"""Test the *colors* parameter of eventplot. Inspired by the issue #8193.
3795-
"""
3794+
"""Test the *colors* parameter of eventplot. Inspired by issue #8193."""
37963795
data = [[i] for i in range(4)] # 4 successive events of different nature
37973796

37983797
# Build the list of the expected colors

‎lib/matplotlib/tests/test_category.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_category.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def __init__(self, units):
5959

6060

6161
class TestStrCategoryConverter:
62-
"""Based on the pandas conversion and factorization tests:
62+
"""
63+
Based on the pandas conversion and factorization tests:
6364
6465
ref: /pandas/tseries/tests/test_converter.py
6566
/pandas/tests/test_algos.py:TestFactorize

‎lib/matplotlib/tests/test_compare_images.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_compare_images.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
('all128.png', 'all127.png', 0, 1),
4444
])
4545
def test_image_comparison_expect_rms(im1, im2, tol, expect_rms):
46-
"""Compare two images, expecting a particular RMS error.
46+
"""
47+
Compare two images, expecting a particular RMS error.
4748
4849
im1 and im2 are filenames relative to the baseline_dir directory.
4950

‎lib/matplotlib/tests/test_widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_widgets.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ def test_slider_horizontal_vertical():
342342

343343

344344
def check_polygon_selector(event_sequence, expected_result, selections_count):
345-
"""Helper function to test Polygon Selector
345+
"""
346+
Helper function to test Polygon Selector.
346347
347348
Parameters
348349
----------

‎lib/matplotlib/text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
@contextlib.contextmanager
2525
def _wrap_text(textobj):
26-
"""Temporarily inserts newlines to the text if the wrap option is enabled.
27-
"""
26+
"""Temporarily inserts newlines if the wrap option is enabled."""
2827
if textobj.get_wrap():
2928
old_text = textobj.get_text()
3029
try:

‎lib/matplotlib/tri/triinterpolate.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tri/triinterpolate.py
+9-12Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,27 +1308,24 @@ def _cg(A, b, x0=None, tol=1.e-10, maxiter=1000):
13081308
A : _Sparse_Matrix_coo
13091309
*A* must have been compressed before by compress_csc or
13101310
compress_csr method.
1311-
13121311
b : array
13131312
Right hand side of the linear system.
1313+
x0 : array, optional
1314+
Starting guess for the solution. Defaults to the zero vector.
1315+
tol : float, optional
1316+
Tolerance to achieve. The algorithm terminates when the relative
1317+
residual is below tol. Default is 1e-10.
1318+
maxiter : int, optional
1319+
Maximum number of iterations. Iteration will stop after *maxiter*
1320+
steps even if the specified tolerance has not been achieved. Defaults
1321+
to 1000.
13141322
13151323
Returns
13161324
-------
13171325
x : array
13181326
The converged solution.
13191327
err : float
13201328
The absolute error np.linalg.norm(A.dot(x) - b)
1321-
1322-
Other parameters
1323-
----------------
1324-
x0 : array
1325-
Starting guess for the solution.
1326-
tol : float
1327-
Tolerance to achieve. The algorithm terminates when the relative
1328-
residual is below tol.
1329-
maxiter : int
1330-
Maximum number of iterations. Iteration will stop after *maxiter*
1331-
steps even if the specified tolerance has not been achieved.
13321329
"""
13331330
n = b.size
13341331
assert A.n == n

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,8 +1597,7 @@ def on_key_press(self, event):
15971597
self._on_key_press(event)
15981598

15991599
def _on_key_press(self, event):
1600-
"""Key press event handler - use for widget-specific key press actions.
1601-
"""
1600+
"""Key press event handler - for widget-specific key press actions."""
16021601

16031602
def on_key_release(self, event):
16041603
"""Key release event handler and validator."""

‎lib/mpl_toolkits/axes_grid1/axes_rgb.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_rgb.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ def _config_axes(self, line_color='w', marker_edge_color='w'):
132132

133133
@cbook.deprecated("3.3")
134134
def add_RGB_to_figure(self):
135-
"""Add the red, green and blue axes to the RGB composite's axes figure
136-
"""
135+
"""Add red, green and blue axes to the RGB composite's axes figure."""
137136
self.RGB.get_figure().add_axes(self.R)
138137
self.RGB.get_figure().add_axes(self.G)
139138
self.RGB.get_figure().add_axes(self.B)

‎tutorials/text/text_intro.py

Copy file name to clipboardExpand all lines: tutorials/text/text_intro.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@
354354

355355

356356
def formatoddticks(x, pos):
357-
"""Format odd tick positions
358-
"""
357+
"""Format odd tick positions."""
359358
if x % 2:
360359
return '%1.2f' % x
361360
else:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.