diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-03-01 09:17:43 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-03-01 09:34:07 +0100 |
commit | 2ad80d92f5e381bda2a7b40e1ee4a81605c7287a (patch) | |
tree | c63fc7f13d5c54ddf24c84cfbb3bd9bbfb519f70 | |
parent | 91f8f1bea24b9a6933f281ad45b42fd2c8f89fef (diff) | |
download | pylint-git-2ad80d92f5e381bda2a7b40e1ee4a81605c7287a.tar.gz |
Exempt `__doc__` from triggering a `redefined-builtin`
`__doc__` can be used to specify a docstring for a module without
passing it as a first-statement string.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pylint/checkers/variables.py | 2 | ||||
-rw-r--r-- | pylint/test/functional/redefined_builtin.py | 1 |
3 files changed, 7 insertions, 1 deletions
@@ -12,6 +12,11 @@ Release date: - Close #1794 + * Exempt `__doc__` from triggering a `redefined-builtin` + + `__doc__` can be used to specify a docstring for a module without + passing it as a first-statement string. + * Fix false positive ``inconsistent-return-statements`` message by avoiding useless exception inference if the exception is not handled. diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index d65da49ce..9d856c3b3 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -501,7 +501,7 @@ class VariablesChecker(BaseChecker): self._to_consume = [NamesConsumer(node, 'module')] for name, stmts in six.iteritems(node.locals): if utils.is_builtin(name) and not utils.is_inside_except(stmts[0]): - if self._should_ignore_redefined_builtin(stmts[0]): + if self._should_ignore_redefined_builtin(stmts[0]) or name == '__doc__': continue self.add_message('redefined-builtin', args=name, node=stmts[0]) diff --git a/pylint/test/functional/redefined_builtin.py b/pylint/test/functional/redefined_builtin.py index d6bca4b72..c840f8dd5 100644 --- a/pylint/test/functional/redefined_builtin.py +++ b/pylint/test/functional/redefined_builtin.py @@ -8,3 +8,4 @@ def function(): # pylint:disable=invalid-name map = {} # [redefined-builtin] +__doc__ = 'reset the doc' |