python-by-example-150-chall.../venv/lib/python3.6/site-packages/pylint/test/functional/unnecessary_pass.py

50 lines
1.1 KiB
Python
Raw Permalink Normal View History

2019-08-04 20:26:35 +08:00
# pylint: disable=missing-docstring, too-few-public-methods
try:
A = 2
except ValueError:
A = 24
pass # [unnecessary-pass]
def docstring_only():
'''In Python, stubbed functions often have a body that contains just a
single `pass` statement, indicating that the function doesn't do
anything. However, a stubbed function can also have just a
docstring, and function with a docstring and no body also does
nothing.
'''
# This function has no docstring, so it needs a `pass` statement.
def pass_only():
pass
def docstring_and_pass():
'''This function doesn't do anything, but it has a docstring, so its
`pass` statement is useless clutter.
NEW CHECK: useless-pass
This would check for stubs with both docstrings and `pass`
statements, suggesting the removal of the useless `pass`
statements
'''
pass # [unnecessary-pass]
class DocstringOnly:
'''The same goes for class stubs: docstring, or `pass`, but not both.
'''
# No problem
class PassOnly:
pass
class DocstringAndPass:
'''Whoops! Mark this one as bad too.
'''
pass # [unnecessary-pass]