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

Skip to content

Commit 52e04f5

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

21 files changed

Lines changed: 73 additions & 62 deletions

File tree

.flake8

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

0 commit comments

Comments
 (0)