@@ -699,6 +699,8 @@ def to_rst(cls):
699699 '"signature"' )
700700D403 = D4xx .create_error ('D403' , 'First word of the first line should be '
701701 'properly capitalized' , '%r, not %r' )
702+ D404 = D4xx .create_error ('D404' , 'First word of the docstring should not '
703+ 'be `This`' )
702704
703705
704706class AttrDict (dict ):
@@ -707,8 +709,10 @@ def __getattr__(self, item):
707709
708710
709711conventions = AttrDict ({
710- 'pep257' : set (ErrorRegistry .get_error_codes ()) - set (['D203' , 'D212' ,
711- 'D213' ])
712+ 'pep257' : set (ErrorRegistry .get_error_codes ()) - set (['D203' ,
713+ 'D212' ,
714+ 'D213' ,
715+ 'D404' ])
712716})
713717
714718
@@ -1431,7 +1435,6 @@ def check_no_blank_before(self, function, docstring): # def
14311435 There's no blank line either before or after the docstring.
14321436
14331437 """
1434- # NOTE: This does not take into account functions with groups of code.
14351438 if docstring :
14361439 before , _ , after = function .source .partition (docstring )
14371440 blanks_before = list (map (is_blank , before .split ('\n ' )[:- 1 ]))
@@ -1680,6 +1683,19 @@ def check_capitalized(self, function, docstring):
16801683 if first_word != first_word .capitalize ():
16811684 return D403 (first_word .capitalize (), first_word )
16821685
1686+ @check_for (Definition )
1687+ def check_starts_with_this (self , function , docstring ):
1688+ """D404: First word of the docstring should not be `This`.
1689+
1690+ Docstrings should use short, simple language. They should not begin
1691+ with "This class is [..]" or "This module contains [..]".
1692+
1693+ """
1694+ if docstring :
1695+ first_word = ast .literal_eval (docstring ).split ()[0 ]
1696+ if first_word .lower () == 'this' :
1697+ return D404 ()
1698+
16831699 # Somewhat hard to determine if return value is mentioned.
16841700 # @check(Function)
16851701 def SKIP_check_return_type (self , function , docstring ):
0 commit comments