@@ -57,18 +57,21 @@ def foo(bar, baz):
57
57
in the argument section.
58
58
3 . If an arguments section is in the function/ method docstring, the argument
59
59
section contains no arguments the function/ method doesn't have.
60
- 4 . If a function/ method has a return statement with a value, the return value
60
+ 4 . Function/ method arguments are only documented once.
61
+ 5 . If a function/ method has a return statement with a value, the return value
61
62
section is included.
62
- 5 . If a function/ method has a yield statement with a value, the yield value
63
+ 6 . If a function/ method has a yield statement with a value, the yield value
63
64
section is included.
64
- 6 . If a function/ method raises an exception, the raises section is included
65
+ 7 . If a function/ method raises an exception, the raises section is included
65
66
with a description for each exception that is raised.
66
- 7 . If a class has public attributes, that the attributes section is included.
67
- 8 . If a class has public attributes, that all public attributes are in the
67
+ 8 . Each raised exception is only described once.
68
+ 9 . If a class has public attributes, that the attributes section is included.
69
+ 10 . If a class has public attributes, that all public attributes are in the
68
70
attributes section.
69
- 9 . If an attributes section is in the class docstring, the attributes section
71
+ 11 . If an attributes section is in the class docstring, the attributes section
70
72
contains no attributes the class doesn't have.
71
- 10 . Any of the sections being checked are not present multiple times.
73
+ 12 . Class attributes are only documented once.
74
+ 13 . Any of the sections being checked are not present multiple times.
72
75
73
76
Note:
74
77
@@ -107,6 +110,8 @@ A few rules have been defined to allow for selective suppression:
107
110
docstring.
108
111
- ` DCO024 ` : function/ method has one or more arguments described in the
109
112
docstring which are not arguments of the function/ method.
113
+ - ` DCO025 ` : function/ method has one or more arguments described in the
114
+ docstring multiple times.
110
115
- ` DCO030 ` : function/ method that returns a value does not have the returns
111
116
section in the docstring.
112
117
- ` DCO031 ` : function/ method that does not return a value has the returns
@@ -131,6 +136,8 @@ A few rules have been defined to allow for selective suppression:
131
136
docstring which are not raised in the function/ method.
132
137
- ` DCO055 ` : function/ method that has a raise without an exception has an empty
133
138
raises section in the docstring.
139
+ - ` DCO056 ` : function/ method has one or more exceptions described in the
140
+ docstring multiple times.
134
141
- ` DCO060 ` : class has one or more public attributes and the docstring does not
135
142
have an attributes section.
136
143
- ` DCO061 ` : class with no attributes and the docstring has an attributes
@@ -141,6 +148,8 @@ A few rules have been defined to allow for selective suppression:
141
148
docstring.
142
149
- ` DCO064 ` : class has one or more attributes described in the docstring which
143
150
are not attributes of the class.
151
+ - ` DCO065 ` : class has one or more attributes described in the docstring
152
+ multiple times.
144
153
145
154
### Fix DCO010
146
155
@@ -446,6 +455,50 @@ class FooClass:
446
455
"""
447
456
```
448
457
458
+ ### Fix DCO025
459
+
460
+ This linting rule is triggered by a function/ method that has one or more
461
+ arguments and a docstring that describes one or more arguments where on or more
462
+ of the described arguments are described multiple times. For example:
463
+
464
+ ``` Python
465
+ def foo (bar ):
466
+ """ Perform foo action.
467
+
468
+ Args:
469
+ bar: the value to perform the foo action on.
470
+ bar: the value to perform the foo action on.
471
+ """
472
+
473
+ class FooClass :
474
+ def foo (self , bar ):
475
+ """ Perform foo action.
476
+
477
+ Args:
478
+ bar: the value to perform the foo action on.
479
+ bar: the value to perform the foo action on.
480
+ """
481
+ ```
482
+
483
+ These examples can be fixed by removing the duplicate arguments from the docstring:
484
+
485
+ ``` Python
486
+ def foo (bar ):
487
+ """ Perform foo action.
488
+
489
+ Args:
490
+ bar: the value to perform the foo action on.
491
+ """
492
+
493
+ class FooClass :
494
+ def foo (self , bar ):
495
+ """ Perform foo action.
496
+
497
+ Args:
498
+ bar: the value to perform the foo action on.
499
+ """
500
+ ```
501
+
449
502
### Fix DCO030
450
503
451
504
This linting rule is triggered by a function/ method that has at least one
@@ -1121,6 +1174,55 @@ class FooClass:
1121
1174
raise
1122
1175
```
1123
1176
1177
+ ### Fix DCO056
1178
+
1179
+ This linting rule is triggered by a function/ method that raises one or more
1180
+ exceptions and a docstring that describes one or more exceptions where on or
1181
+ more of the described exceptions are described multiple times. For example:
1182
+
1183
+ ``` Python
1184
+ def foo ():
1185
+ """ Perform foo action.
1186
+
1187
+ Raises:
1188
+ BarError: the value to perform the foo action on was wrong.
1189
+ BarError: the value to perform the foo action on was wrong.
1190
+ """
1191
+ raise BarError
1192
+
1193
+ class FooClass :
1194
+ def foo (self ):
1195
+ """ Perform foo action.
1196
+
1197
+ Raises:
1198
+ BarError: the value to perform the foo action on was wrong.
1199
+ BarError: the value to perform the foo action on was wrong.
1200
+ """
1201
+ raise BarError
1202
+ ```
1203
+
1204
+ These examples can be fixed by removing the duplicate descriptions from the
1205
+ docstring:
1206
+
1207
+ ``` Python
1208
+ def foo ():
1209
+ """ Perform foo action.
1210
+
1211
+ Raises:
1212
+ BarError: the value to perform the foo action on was wrong.
1213
+ """
1214
+ raise BarError
1215
+
1216
+ class FooClass :
1217
+ def foo (self ):
1218
+ """ Perform foo action.
1219
+
1220
+ Raises:
1221
+ BarError: the value to perform the foo action on was wrong.
1222
+ """
1223
+ raise BarError
1224
+ ```
1225
+
1124
1226
### Fix DCO060
1125
1227
1126
1228
This linting rule is triggered by a class that has one or more public
@@ -1431,6 +1533,61 @@ class FooClass:
1431
1533
self .bar = " bar"
1432
1534
```
1433
1535
1536
+ ### Fix DCO065
1537
+
1538
+ This linting rule is triggered by a class that has one or more attributes and a
1539
+ docstring that describes one or more attributes where on or more
1540
+ of the described attributes are described multiple times. For example:
1541
+
1542
+ ``` Python
1543
+ class FooClass :
1544
+ """ Perform foo action.
1545
+
1546
+ Attrs:
1547
+ bar: The value to perform the foo action on.
1548
+ bar: The value to perform the foo action on.
1549
+ """
1550
+
1551
+ bar = " bar"
1552
+
1553
+ class FooClass :
1554
+ """ Perform foo action.
1555
+
1556
+ Attrs:
1557
+ bar: The value to perform the foo action on.
1558
+ bar: The value to perform the foo action on.
1559
+ """
1560
+
1561
+ def __init__ (self ):
1562
+ """ Construct."""
1563
+ self .bar = " bar"
1564
+ ```
1565
+
1566
+ These examples can be fixed by removing the duplicate descriptions from the
1567
+ docstring:
1568
+
1569
+ ``` Python
1570
+ class FooClass :
1571
+ """ Perform foo action.
1572
+
1573
+ Attrs:
1574
+ bar: The value to perform the foo action on.
1575
+ """
1576
+
1577
+ bar = " bar"
1578
+
1579
+ class FooClass :
1580
+ """ Perform foo action.
1581
+
1582
+ Attrs:
1583
+ bar: The value to perform the foo action on.
1584
+ """
1585
+
1586
+ def __init__ (self ):
1587
+ """ Construct."""
1588
+ self .bar = " bar"
1589
+ ```
1590
+
1434
1591
## Docstring Examples
1435
1592
1436
1593
Examples of function/ method and class docstrings are:
0 commit comments