Debian Codegraph @

tests/functional/u/unnecessary/unnecessary_pass.py

raw symbols SCIP
1 # pylint: disable=missing-docstring, too-few-public-methods
2
3 try:
4 A = 2
5 except ValueError:
6 A = 24
7 pass # [unnecessary-pass]
8
9 def docstring_only():
10 '''In Python, stubbed functions often have a body that contains just a
11 single `pass` statement, indicating that the function doesn't do
12 anything. However, a stubbed function can also have just a
13 docstring, and function with a docstring and no body also does
14 nothing.
15 '''
16
17
18 # This function has no docstring, so it needs a `pass` statement.
19 def pass_only():
20 pass
21
22
23 def docstring_and_pass():
24 '''This function doesn't do anything, but it has a docstring, so its
25 `pass` statement is useless clutter.
26
27 NEW CHECK: useless-pass
28
29 This would check for stubs with both docstrings and `pass`
30 statements, suggesting the removal of the useless `pass`
31 statements
32 '''
33 pass # [unnecessary-pass]
34
35
36 class DocstringOnly:
37 '''The same goes for class stubs: docstring, or `pass`, but not both.
38 '''
39
40
41 # No problem
42 class PassOnly:
43 pass
44
45
46 class DocstringAndPass:
47 '''Whoops! Mark this one as bad too.
48 '''
49 pass # [unnecessary-pass]