diff options
author | hippo91 <guillaume.peillex@gmail.com> | 2020-09-03 19:26:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 19:26:31 +0200 |
commit | 969878c485003dbdd1e5774b52710e77a7131cd5 (patch) | |
tree | fb5cd4701a23b5d740d66d1d51ee0024577216db | |
parent | a59c2bfe74ccc8c4c97a2174e2d8234de38f561f (diff) | |
parent | 2261844748be0f881719963d2fb5932dd4e4a2e2 (diff) | |
download | pylint-git-969878c485003dbdd1e5774b52710e77a7131cd5.tar.gz |
Merge branch 'master' into bug_pylint_3468
110 files changed, 416 insertions, 128 deletions
diff --git a/.travis.yml b/.travis.yml index 3384e7319..61d78d4d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,9 @@ before_install: - sudo apt-get -qq update - sudo apt-get install -y enchant install: +# Temporary escape hatch for setuptools 50.0: +# See https://github.com/pypa/setuptools/blob/17cb9d6bf249cefe653d3bdb712582409035a7db/CHANGES.rst#v5000 +- export SETUPTOOLS_USE_DISTUTILS=stdlib - pip install -U setuptools - pip install tox coverage coveralls - virtualenv --version diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index d3aea5e1c..4d57c4de0 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -394,4 +394,6 @@ contributors: * Ram Rachum (cool-RR) -* Pieter Engelbrecht
\ No newline at end of file +* Pieter Engelbrecht + +* Ethan Leba: contributor @@ -2,7 +2,7 @@ Pylint's ChangeLog ------------------ -What's New in Pylint 2.6.0? +What's New in Pylint 2.6.1? =========================== Release date: TBA @@ -12,6 +12,11 @@ Release date: TBA Closes #3468 +What's New in Pylint 2.6.0? +=========================== + +Release date: 2020-08-20 + * Fix various scope-related bugs in ``undefined-variable`` checker Close #1082, #3434, #3461 @@ -56,6 +61,13 @@ Release date: TBA Close #3722 +* Add check for bool function to `len-as-condition` + +* Add `simplifiable-condition` check for extraneous constants in conditionals using and/or. + +* Add `condition-evals-to-constant` check for conditionals using and/or that evaluate to a constant. + + Close #3407 What's New in Pylint 2.5.4? =========================== diff --git a/README.rst b/README.rst index 20e053f72..6522d7b07 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ README for Pylint - https://pylint.pycqa.org/ -============================================ +============================================= .. image:: https://travis-ci.org/PyCQA/pylint.svg?branch=master :target: https://travis-ci.org/PyCQA/pylint diff --git a/doc/whatsnew/2.6.rst b/doc/whatsnew/2.6.rst index 1d5f45123..d6cb313ec 100644 --- a/doc/whatsnew/2.6.rst +++ b/doc/whatsnew/2.6.rst @@ -3,7 +3,7 @@ ************************** :Release: 2.6 -:Date: TBA +:Date: 2020-08-20 Summary -- Release highlights @@ -17,6 +17,10 @@ New checkers * Add `raise-missing-from` check for exceptions that should have a cause. +* Add `simplifiable-condition` check for extraneous constants in conditionals using and/or. + +* Add `condition-evals-to-constant` check for conditionals using and/or that evaluate to a constant. + Other Changes ============= diff --git a/pylint/__pkginfo__.py b/pylint/__pkginfo__.py index fc3d79ebd..a8d575dd7 100644 --- a/pylint/__pkginfo__.py +++ b/pylint/__pkginfo__.py @@ -14,10 +14,13 @@ # Copyright (c) 2018-2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> -# Copyright (c) 2019 Ville Skyttä <ville.skytta@iki.fi> +# Copyright (c) 2019-2020 Ville Skyttä <ville.skytta@iki.fi> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Dan Hemberger <846186+hemberger@users.noreply.github.com> # Copyright (c) 2019 jab <jab@users.noreply.github.com> +# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> +# Copyright (c) 2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING @@ -29,8 +32,8 @@ from os.path import join # For an official release, use dev_version = None -numversion = (2, 6, 0) -dev_version = "1" +numversion = (2, 6, 1) +dev_version = 1 version = ".".join(str(num) for num in numversion) if dev_version is not None: diff --git a/pylint/checkers/__init__.py b/pylint/checkers/__init__.py index 5c2be6ab5..921a54a2f 100644 --- a/pylint/checkers/__init__.py +++ b/pylint/checkers/__init__.py @@ -1,7 +1,7 @@ # Copyright (c) 2006-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2013-2014 Google, Inc. # Copyright (c) 2013 buck@yelp.com <buck@yelp.com> -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> diff --git a/pylint/checkers/async.py b/pylint/checkers/async.py index 62288c8fc..1b581c0f1 100644 --- a/pylint/checkers/async.py +++ b/pylint/checkers/async.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index d284ea37d..d830a68ba 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -44,6 +44,8 @@ # Copyright (c) 2019 Nikita Sobolev <mail@sobolevn.me> # Copyright (c) 2019 Oisín Moran <OisinMoran@users.noreply.github.com> # Copyright (c) 2019 Fantix King <fantix@uchicago.edu> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> +# Copyright (c) 2020 Ram Rachum <ram@rachum.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2020 bernie gray <bfgray3@users.noreply.github.com> # Copyright (c) 2020 Gabriel R Sezefredo <g@briel.dev> diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py index 2f074fe74..b1f6fe25b 100644 --- a/pylint/checkers/base_checker.py +++ b/pylint/checkers/base_checker.py @@ -1,7 +1,7 @@ # Copyright (c) 2006-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2013-2014 Google, Inc. # Copyright (c) 2013 buck@yelp.com <buck@yelp.com> -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> diff --git a/pylint/checkers/design_analysis.py b/pylint/checkers/design_analysis.py index fb447667b..8e3fe064d 100644 --- a/pylint/checkers/design_analysis.py +++ b/pylint/checkers/design_analysis.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2006, 2009-2010, 2012-2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012, 2014 Google, Inc. -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com> diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py index 957938454..3e683fa02 100644 --- a/pylint/checkers/exceptions.py +++ b/pylint/checkers/exceptions.py @@ -2,7 +2,7 @@ # Copyright (c) 2006-2011, 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2011-2014 Google, Inc. # Copyright (c) 2012 Tim Hatch <tim@timhatch.com> -# Copyright (c) 2013-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2013-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Rene Zhang <rz99@cornell.edu> @@ -24,6 +24,7 @@ # Copyright (c) 2019 Djailla <bastien.vallet@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Ram Rachum <ram@rachum.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py index 52d852a25..13e6f7ada 100644 --- a/pylint/checkers/format.py +++ b/pylint/checkers/format.py @@ -2,7 +2,7 @@ # Copyright (c) 2006-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012-2015 Google, Inc. # Copyright (c) 2013 moxian <aleftmail@inbox.ru> -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 frost-nzcr4 <frost.nzcr4@jagmort.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Michal Nowikowski <godfryd@gmail.com> @@ -16,12 +16,13 @@ # Copyright (c) 2016 Petr Pulc <petrpulc@gmail.com> # Copyright (c) 2016 Moises Lopez <moylop260@vauxoo.com> # Copyright (c) 2016 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2017, 2019 hippo91 <guillaume.peillex@gmail.com> # Copyright (c) 2017-2018 Bryce Guinta <bryce.paul.guinta@gmail.com> +# Copyright (c) 2017, 2019 hippo91 <guillaume.peillex@gmail.com> # Copyright (c) 2017 Krzysztof Czapla <k.czapla68@gmail.com> # Copyright (c) 2017 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2017 James M. Allen <james.m.allen@gmail.com> # Copyright (c) 2017 vinnyrose <vinnyrose@users.noreply.github.com> +# Copyright (c) 2018, 2020 Bryce Guinta <bryce.guinta@protonmail.com> # Copyright (c) 2018-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2018 Pierre Sassoulas <pierre.sassoulas@wisebim.fr> # Copyright (c) 2018, 2020 Anthony Sottile <asottile@umich.edu> @@ -30,7 +31,6 @@ # Copyright (c) 2018 Natalie Serebryakova <natalie.serebryakova@Natalies-MacBook-Pro.local> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2018 Marcus Näslund <naslundx@gmail.com> -# Copyright (c) 2018 Bryce Guinta <bryce.guinta@protonmail.com> # Copyright (c) 2018 Mike Frysinger <vapier@gmail.com> # Copyright (c) 2018 Fureigh <rhys.fureigh@gsa.gov> # Copyright (c) 2018 Andreas Freimuth <andreas.freimuth@united-bits.de> diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 4b97b5e14..a39c9ebbe 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -32,6 +32,7 @@ # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Nick Smith <clickthisnick@users.noreply.github.com> # Copyright (c) 2019 Paul Renvoisé <renvoisepaul@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/checkers/misc.py b/pylint/checkers/misc.py index 0d1eac8a8..eb76c8c28 100644 --- a/pylint/checkers/misc.py +++ b/pylint/checkers/misc.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2006, 2009-2013 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012-2014 Google, Inc. -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Alexandru Coman <fcoman@bitdefender.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py index 9aaa846d4..3da27a3dd 100644 --- a/pylint/checkers/newstyle.py +++ b/pylint/checkers/newstyle.py @@ -1,6 +1,6 @@ # Copyright (c) 2006, 2008-2011, 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012-2014 Google, Inc. -# Copyright (c) 2013-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2013-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py index 1bc3211f9..4e60873a0 100644 --- a/pylint/checkers/python3.py +++ b/pylint/checkers/python3.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014-2015 Brett Cannon <brett@python.org> # Copyright (c) 2015 Simu Toni <simutoni@gmail.com> # Copyright (c) 2015 Pavel Roskin <proski@gnu.org> @@ -29,6 +29,8 @@ # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 bluesheeptoken <louis.fruleux1@gmail.com> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> +# Copyright (c) 2020 Federico Bond <federicobond@gmail.com> # Copyright (c) 2020 Athos Ribeiro <athoscr@fedoraproject.org> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/checkers/raw_metrics.py b/pylint/checkers/raw_metrics.py index 0016eb2a4..8fed7b614 100644 --- a/pylint/checkers/raw_metrics.py +++ b/pylint/checkers/raw_metrics.py @@ -1,12 +1,14 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2007, 2010, 2013, 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2013 Google, Inc. # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Mike Frysinger <vapier@gentoo.org> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/checkers/refactoring.py b/pylint/checkers/refactoring.py index 2c6226bb1..28d90f155 100644 --- a/pylint/checkers/refactoring.py +++ b/pylint/checkers/refactoring.py @@ -26,6 +26,7 @@ # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 PHeanEX <github@pheanex.de> # Copyright (c) 2019 Paul Renvoise <PaulRenvoise@users.noreply.github.com> +# Copyright (c) 2020 lrjball <50599110+lrjball@users.noreply.github.com> # Copyright (c) 2020 Yang Yang <y4n9squared@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> @@ -35,9 +36,11 @@ """Looks for code which can be refactored.""" import builtins import collections +import copy import itertools import tokenize from functools import reduce +from typing import Optional import astroid from astroid import decorators @@ -58,24 +61,10 @@ def _if_statement_is_always_returning(if_node, returning_node_class): return False -def _is_len_call(node): - """Checks if node is len(SOMETHING).""" - return ( - isinstance(node, astroid.Call) - and isinstance(node.func, astroid.Name) - and node.func.name == "len" - ) - - def _is_constant_zero(node): return isinstance(node, astroid.Const) and node.value == 0 -def _node_is_test_condition(node): - """ Checks if node is an if, while, assert or if expression statement.""" - return isinstance(node, (astroid.If, astroid.While, astroid.Assert, astroid.IfExp)) - - def _is_trailing_comma(tokens, index): """Check if the given token is a trailing comma @@ -121,6 +110,28 @@ def _is_trailing_comma(tokens, index): return False +def _is_call_of_name(node: astroid.node_classes.NodeNG, name: str) -> bool: + """Checks if node is a function call with the given name""" + return ( + isinstance(node, astroid.Call) + and isinstance(node.func, astroid.Name) + and node.func.name == name + ) + + +def _is_test_condition( + node: astroid.node_classes.NodeNG, + parent: Optional[astroid.node_classes.NodeNG] = None, +) -> bool: + """Returns true if the given node is being tested for truthiness""" + parent = parent or node.parent + if isinstance(parent, (astroid.While, astroid.If, astroid.IfExp, astroid.Assert)): + return node is parent.test or parent.test.parent_of(node) + if isinstance(parent, astroid.Comprehension): + return node in parent.ifs + return _is_call_of_name(parent, "bool") and parent.parent_of(node) + + class RefactoringChecker(checkers.BaseTokenChecker): """Looks for code which can be refactored @@ -149,6 +160,16 @@ class RefactoringChecker(checkers.BaseTokenChecker): "simplify-boolean-expression", "Emitted when redundant pre-python 2.5 ternary syntax is used.", ), + "R1726": ( + "Boolean condition '%s' may be simplified to '%s'", + "simplifiable-condition", + "Emitted when a boolean condition is able to be simplified.", + ), + "R1727": ( + "Boolean condition '%s' will always evaluate to '%s'", + "condition-evals-to-constant", + "Emitted when a boolean condition can be simplified to a constant value.", + ), "R1702": ( "Too many nested blocks (%s/%s)", "too-many-nested-blocks", @@ -353,6 +374,7 @@ class RefactoringChecker(checkers.BaseTokenChecker): self._elifs = [] self._nested_blocks_msg = None self._reported_swap_nodes = set() + self._can_simplify_bool_op = False def open(self): # do this in open since config not fully initialized in __init__ @@ -984,13 +1006,92 @@ class RefactoringChecker(checkers.BaseTokenChecker): self.add_message("chained-comparison", node=node) break + @staticmethod + def _apply_boolean_simplification_rules(operator, values): + """Removes irrelevant values or returns shortcircuiting values + + This function applies the following two rules: + 1) an OR expression with True in it will always be true, and the + reverse for AND + + 2) False values in OR expressions are only relevant if all values are + false, and the reverse for AND""" + simplified_values = [] + + for subnode in values: + inferred_bool = None + if not next(subnode.nodes_of_class(astroid.Name), False): + inferred = utils.safe_infer(subnode) + if inferred: + inferred_bool = inferred.bool_value() + + if not isinstance(inferred_bool, bool): + simplified_values.append(subnode) + elif (operator == "or") == inferred_bool: + return [subnode] + + return simplified_values or [astroid.Const(operator == "and")] + + def _simplify_boolean_operation(self, bool_op): + """Attempts to simplify a boolean operation + + Recursively applies simplification on the operator terms, + and keeps track of whether reductions have been made.""" + children = list(bool_op.get_children()) + intermediate = [ + self._simplify_boolean_operation(child) + if isinstance(child, astroid.BoolOp) + else child + for child in children + ] + result = self._apply_boolean_simplification_rules(bool_op.op, intermediate) + if len(result) < len(children): + self._can_simplify_bool_op = True + if len(result) == 1: + return result[0] + simplified_bool_op = copy.copy(bool_op) + simplified_bool_op.postinit(result) + return simplified_bool_op + + def _check_simplifiable_condition(self, node): + """Check if a boolean condition can be simplified. + + Variables will not be simplified, even in the value can be inferred, + and expressions like '3 + 4' will remain expanded.""" + if not _is_test_condition(node): + return + + self._can_simplify_bool_op = False + simplified_expr = self._simplify_boolean_operation(node) + + if not self._can_simplify_bool_op: + return + + if not next(simplified_expr.nodes_of_class(astroid.Name), False): + self.add_message( + "condition-evals-to-constant", + node=node, + args=(node.as_string(), simplified_expr.as_string()), + ) + else: + self.add_message( + "simplifiable-condition", + node=node, + args=(node.as_string(), simplified_expr.as_string()), + ) + @utils.check_messages( - "consider-merging-isinstance", "consider-using-in", "chained-comparison" + "consider-merging-isinstance", + "consider-using-in", + "chained-comparison", + "simplifiable-condition", + "condition-evals-to-constant", ) def visit_boolop(self, node): self._check_consider_merging_isinstance(node) self._check_consider_using_in(node) self._check_chained_comparison(node) + self._check_simplifiable_condition(node) @staticmethod def _is_simple_assignment(node): @@ -1550,6 +1651,7 @@ class LenChecker(checkers.BaseChecker): * while not len(sequence): * assert len(sequence): * assert not len(sequence): + * bool(len(sequence)) """ __implements__ = (interfaces.IAstroidChecker,) @@ -1576,7 +1678,7 @@ class LenChecker(checkers.BaseChecker): # a len(S) call is used inside a test condition # could be if, while, assert or if expression statement # e.g. `if len(S):` - if _is_len_call(node): + if _is_call_of_name(node, "len"): # the len() call could also be nested together with other # boolean operations, e.g. `if z or len(x):` parent = node.parent @@ -1585,11 +1687,8 @@ class LenChecker(checkers.BaseChecker): # we're finally out of any nested boolean operations so check if # this len() call is part of a test condition - if not _node_is_test_condition(parent): - return - if not (node is parent.test or parent.test.parent_of(node)): - return - self.add_message("len-as-condition", node=node) + if _is_test_condition(node, parent): + self.add_message("len-as-condition", node=node) @utils.check_messages("len-as-condition") def visit_unaryop(self, node): @@ -1599,7 +1698,7 @@ class LenChecker(checkers.BaseChecker): if ( isinstance(node, astroid.UnaryOp) and node.op == "not" - and _is_len_call(node.operand) + and _is_call_of_name(node.operand, "len") ): self.add_message("len-as-condition", node=node) diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index 99c5ecbb1..58dc0f807 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -2,7 +2,7 @@ # Copyright (c) 2012 Ry4an Brase <ry4an-hg@ry4an.org> # Copyright (c) 2012 Google, Inc. # Copyright (c) 2012 Anthony VEREZ <anthony.verez.external@cassidian.com> -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> @@ -13,6 +13,7 @@ # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Taewon D. Kim <kimt33@mcmaster.ca> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Shiv Venkatasubrahmanyam <shvenkat@users.noreply.github.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/checkers/spelling.py b/pylint/checkers/spelling.py index dea75bef8..ff6d04620 100644 --- a/pylint/checkers/spelling.py +++ b/pylint/checkers/spelling.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2015 Pavel Roskin <proski@gnu.org> @@ -15,6 +15,7 @@ # Copyright (c) 2019 Peter Kolbus <peter.kolbus@gmail.com> # Copyright (c) 2019 agutole <toldo_carp@hotmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index 587a1a082..06a700c1c 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2013-2014 Google, Inc. -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Cosmin Poieana <cmin@ropython.org> # Copyright (c) 2014 Vlad Temian <vladtemian@gmail.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> @@ -22,6 +22,7 @@ # Copyright (c) 2019 Robert Schweizer <robert_schweizer@gmx.de> # Copyright (c) 2019 fadedDexofan <fadedDexofan@gmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py index 9b8cbdc7d..28f6083e5 100644 --- a/pylint/checkers/strings.py +++ b/pylint/checkers/strings.py @@ -22,6 +22,7 @@ # Copyright (c) 2019 Djailla <bastien.vallet@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> # Copyright (c) 2020 Anthony <tanant@users.noreply.github.com> diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 3c28b92c7..d28516be8 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -38,6 +38,7 @@ # Copyright (c) 2019 yory8 <39745367+yory8@users.noreply.github.com> # Copyright (c) 2019 Federico Bond <federicobond@gmail.com> # Copyright (c) 2019 Pascal Corpet <pcorpet@users.noreply.github.com> +# Copyright (c) 2020 Ram Rachum <ram@rachum.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2020 Anubhav <35621759+anubh-v@users.noreply.github.com> diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index e413ab199..d61418615 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -34,6 +34,9 @@ # Copyright (c) 2019 Nathan Marrow <nmarrow@google.com> # Copyright (c) 2019 Svet <svet@hyperscience.com> # Copyright (c) 2019 Pascal Corpet <pcorpet@users.noreply.github.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> +# Copyright (c) 2020 Andrew Simmons <anjsimmo@gmail.com> +# Copyright (c) 2020 Ram Rachum <ram@rachum.com> # Copyright (c) 2020 Slavfox <slavfoxman@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index 951cc62a9..aa0af51b1 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -36,6 +36,7 @@ # Copyright (c) 2019 Djailla <bastien.vallet@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Andrew Simmons <anjsimmo@gmail.com> # Copyright (c) 2020 Andrew Simmons <a.simmons@deakin.edu.au> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2020 Ashley Whetter <ashleyw@activestate.com> diff --git a/pylint/config/__init__.py b/pylint/config/__init__.py index 7f1407d78..8626135c7 100644 --- a/pylint/config/__init__.py +++ b/pylint/config/__init__.py @@ -25,10 +25,10 @@ # Copyright (c) 2018 Gary Tyler McLeod <mail@garytyler.com> # Copyright (c) 2018 Konstantin <Github@pheanex.de> # Copyright (c) 2018 Nick Drozd <nicholasdrozd@gmail.com> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Janne Rönkkö <jannero@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/epylint.py b/pylint/epylint.py index ba629af1d..276a708df 100755 --- a/pylint/epylint.py +++ b/pylint/epylint.py @@ -8,7 +8,7 @@ # Copyright (c) 2014 Manuel Vázquez Acosta <mva.led@gmail.com> # Copyright (c) 2014 Derek Harland <derek.harland@finq.co.nz> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Mihai Balint <balint.mihai@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2017 hippo91 <guillaume.peillex@gmail.com> @@ -19,6 +19,7 @@ # Copyright (c) 2018 Radostin Stoyanov <rst0git@users.noreply.github.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/exceptions.py b/pylint/exceptions.py index da91e2f2a..0cb4a0aee 100644 --- a/pylint/exceptions.py +++ b/pylint/exceptions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> # Copyright (c) 2017 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi> diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py index e9dc4dfe5..14ca24e9a 100644 --- a/pylint/extensions/_check_docs_utils.py +++ b/pylint/extensions/_check_docs_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2016 Yuri Bochkarev <baltazar.bz@gmail.com> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> diff --git a/pylint/extensions/bad_builtin.py b/pylint/extensions/bad_builtin.py index c04110182..49aa5a8f9 100644 --- a/pylint/extensions/bad_builtin.py +++ b/pylint/extensions/bad_builtin.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016, 2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016, 2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/pylint/extensions/broad_try_clause.py b/pylint/extensions/broad_try_clause.py index 83871a2b6..d28ba5ac5 100644 --- a/pylint/extensions/broad_try_clause.py +++ b/pylint/extensions/broad_try_clause.py @@ -1,5 +1,5 @@ +# Copyright (c) 2019-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2019-2020 Tyler Thieding <tyler@thieding.com> -# Copyright (c) 2019 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/extensions/check_docs.py b/pylint/extensions/check_docs.py index ec5e68876..da8f7cab2 100644 --- a/pylint/extensions/check_docs.py +++ b/pylint/extensions/check_docs.py @@ -1,5 +1,5 @@ # Copyright (c) 2014-2015 Bruno Daniel <bruno.daniel@blue-yonder.com> -# Copyright (c) 2015-2016, 2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2016, 2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Ashley Whetter <ashley@awhetter.co.uk> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/extensions/check_elif.py b/pylint/extensions/check_elif.py index 2800f752a..220b6b833 100644 --- a/pylint/extensions/check_elif.py +++ b/pylint/extensions/check_elif.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> -# Copyright (c) 2016-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Glenn Matthews <glmatthe@cisco.com> # Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/pylint/extensions/comparetozero.py b/pylint/extensions/comparetozero.py index 007c7918e..2df0174c8 100644 --- a/pylint/extensions/comparetozero.py +++ b/pylint/extensions/comparetozero.py @@ -1,5 +1,5 @@ # Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg> -# Copyright (c) 2017-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/pylint/extensions/docparams.py b/pylint/extensions/docparams.py index 9db49864d..c2626d5fc 100644 --- a/pylint/extensions/docparams.py +++ b/pylint/extensions/docparams.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2014-2015 Bruno Daniel <bruno.daniel@blue-yonder.com> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> # Copyright (c) 2016 Glenn Matthews <glmatthe@cisco.com> @@ -13,6 +13,7 @@ # Copyright (c) 2018 Adam Dangoor <adamdangoor@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/pylint/extensions/docstyle.py b/pylint/extensions/docstyle.py index 4e6f7dc22..249d4b80f 100644 --- a/pylint/extensions/docstyle.py +++ b/pylint/extensions/docstyle.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2016 Luis Escobar <lescobar@vauxoo.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/pylint/extensions/emptystring.py b/pylint/extensions/emptystring.py index c6ea0c26d..1c2c5cec8 100644 --- a/pylint/extensions/emptystring.py +++ b/pylint/extensions/emptystring.py @@ -1,5 +1,5 @@ # Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg> -# Copyright (c) 2017-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/pylint/extensions/mccabe.py b/pylint/extensions/mccabe.py index 19c0514ca..7865551d1 100644 --- a/pylint/extensions/mccabe.py +++ b/pylint/extensions/mccabe.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Moises Lopez <moylop260@vauxoo.com> # Copyright (c) 2017 hippo91 <guillaume.peillex@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> diff --git a/pylint/extensions/redefined_variable_type.py b/pylint/extensions/redefined_variable_type.py index b81443e0c..9687e78d8 100644 --- a/pylint/extensions/redefined_variable_type.py +++ b/pylint/extensions/redefined_variable_type.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Glenn Matthews <glmatthe@cisco.com> # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> # Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi> diff --git a/pylint/graph.py b/pylint/graph.py index 219d0b392..d58ecd9f1 100644 --- a/pylint/graph.py +++ b/pylint/graph.py @@ -1,9 +1,12 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# -*- coding: utf-8 -*- +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Florian Bruhin <me@the-compiler.org> # Copyright (c) 2016 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2019 Nick Drozd <nicholasdrozd@gmail.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> # Copyright (c) 2020 Benjamin Graham <benwilliamgraham@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/interfaces.py b/pylint/interfaces.py index 11d4171fb..305e001ee 100644 --- a/pylint/interfaces.py +++ b/pylint/interfaces.py @@ -3,7 +3,7 @@ # Copyright (c) 2013-2014 Google, Inc. # Copyright (c) 2014 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Florian Bruhin <me@the-compiler.org> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> diff --git a/pylint/message/__init__.py b/pylint/message/__init__.py index 6b92aa0f0..dc2c77151 100644 --- a/pylint/message/__init__.py +++ b/pylint/message/__init__.py @@ -3,7 +3,7 @@ # Copyright (c) 2009 Vincent # Copyright (c) 2009 Mads Kiilerich <mads@kiilerich.com> # Copyright (c) 2012-2014 Google, Inc. -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014-2015 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2014 LCD 47 <lcd047@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> diff --git a/pylint/pyreverse/diadefslib.py b/pylint/pyreverse/diadefslib.py index 2907a08e1..8d9140829 100644 --- a/pylint/pyreverse/diadefslib.py +++ b/pylint/pyreverse/diadefslib.py @@ -2,7 +2,7 @@ # Copyright (c) 2006, 2008-2010, 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Florian Bruhin <me@the-compiler.org> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Ashley Whetter <ashley@awhetter.co.uk> diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py index c83081621..8c5eb485d 100644 --- a/pylint/pyreverse/diagrams.py +++ b/pylint/pyreverse/diagrams.py @@ -1,5 +1,5 @@ # Copyright (c) 2006, 2008-2010, 2012-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py index 4221b9d19..676da93e9 100644 --- a/pylint/pyreverse/inspector.py +++ b/pylint/pyreverse/inspector.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2017 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi> diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index 540b888f8..2cd689dcd 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -1,7 +1,7 @@ # Copyright (c) 2008-2010, 2012-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Alexander Pervakov <frost.nzcr4@jagmort.com> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> diff --git a/pylint/pyreverse/utils.py b/pylint/pyreverse/utils.py index f0a22ef6e..ed0416078 100644 --- a/pylint/pyreverse/utils.py +++ b/pylint/pyreverse/utils.py @@ -1,7 +1,7 @@ # Copyright (c) 2006, 2008, 2010, 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2017 hippo91 <guillaume.peillex@gmail.com> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> diff --git a/pylint/pyreverse/vcgutils.py b/pylint/pyreverse/vcgutils.py index 9c17c7852..d6dc40484 100644 --- a/pylint/pyreverse/vcgutils.py +++ b/pylint/pyreverse/vcgutils.py @@ -1,6 +1,9 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# -*- coding: utf-8 -*- +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Florian Bruhin <me@the-compiler.org> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> +# Copyright (c) 2020 Ram Rachum <ram@rachum.com> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py index 0a7402c9f..dc937a9e8 100644 --- a/pylint/reporters/__init__.py +++ b/pylint/reporters/__init__.py @@ -2,7 +2,7 @@ # Copyright (c) 2006, 2010, 2012-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012-2014 Google, Inc. # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Ricardo Gemignani <ricardo.gemignani@gmail.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> diff --git a/pylint/reporters/json_reporter.py b/pylint/reporters/json_reporter.py index 6f151cd55..76117de5b 100644 --- a/pylint/reporters/json_reporter.py +++ b/pylint/reporters/json_reporter.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2014 Vlad Temian <vladtemian@gmail.com> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2017 guillaume2 <guillaume.peillex@gmail.col> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py index dc400c119..9321bac57 100644 --- a/pylint/reporters/text.py +++ b/pylint/reporters/text.py @@ -2,7 +2,7 @@ # Copyright (c) 2012-2014 Google, Inc. # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Florian Bruhin <me@the-compiler.org> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 y2kbugger <y2kbugger@users.noreply.github.com> diff --git a/pylint/reporters/ureports/__init__.py b/pylint/reporters/ureports/__init__.py index a5a6396a5..a3bda15e9 100644 --- a/pylint/reporters/ureports/__init__.py +++ b/pylint/reporters/ureports/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016, 2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2016, 2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> # Copyright (c) 2018 Anthony Sottile <asottile@umich.edu> diff --git a/pylint/reporters/ureports/nodes.py b/pylint/reporters/ureports/nodes.py index c7af824e6..3dd72e703 100644 --- a/pylint/reporters/ureports/nodes.py +++ b/pylint/reporters/ureports/nodes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016, 2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2016, 2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> # Copyright (c) 2018 Nick Drozd <nicholasdrozd@gmail.com> diff --git a/pylint/reporters/ureports/text_writer.py b/pylint/reporters/ureports/text_writer.py index 9d426e123..923fdbec5 100644 --- a/pylint/reporters/ureports/text_writer.py +++ b/pylint/reporters/ureports/text_writer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016, 2018-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2016, 2018-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2018, 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/pylint/testutils.py b/pylint/testutils.py index a1b03aa8a..70cc1f15c 100644 --- a/pylint/testutils.py +++ b/pylint/testutils.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2012-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> # Copyright (c) 2013-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> @@ -18,6 +19,7 @@ # Copyright (c) 2019 Mr. Senko <atodorov@mrsenko.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 谭九鼎 <109224573@qq.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/pylint/utils/__init__.py b/pylint/utils/__init__.py index e03938387..ba7d43a34 100644 --- a/pylint/utils/__init__.py +++ b/pylint/utils/__init__.py @@ -3,7 +3,7 @@ # Copyright (c) 2009 Vincent # Copyright (c) 2009 Mads Kiilerich <mads@kiilerich.com> # Copyright (c) 2012-2014 Google, Inc. -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014-2015 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2014 LCD 47 <lcd047@gmail.com> # Copyright (c) 2014 Brett Cannon <brett@python.org> @@ -35,6 +35,7 @@ # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> # Copyright (c) 2018 Reverb C <reverbc@users.noreply.github.com> # Copyright (c) 2018 Nick Drozd <nicholasdrozd@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- #!/usr/bin/env python # pylint: disable=W0404,W0622,W0613 # Copyright (c) 2006, 2009-2010, 2012-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> @@ -5,7 +6,7 @@ # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> # Copyright (c) 2013 Benedikt Morbach <benedikt.morbach@googlemail.com> # Copyright (c) 2013 T.Rzepka <Tobias.Rzepka@gmail.com> -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Pedro Algarvio <pedro@algarvio.me> # Copyright (c) 2014 Brett Cannon <brett@python.org> # Copyright (c) 2014 Google, Inc. @@ -17,6 +18,9 @@ # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> +# Copyright (c) 2020 Bryce Guinta <bryce.guinta@protonmail.com> +# Copyright (c) 2020 Ville Skyttä <ville.skytta@iki.fi> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/benchmark/test_baseline_benchmarks.py b/tests/benchmark/test_baseline_benchmarks.py index d3e09f716..d9899ce99 100644 --- a/tests/benchmark/test_baseline_benchmarks.py +++ b/tests/benchmark/test_baseline_benchmarks.py @@ -1,4 +1,5 @@ """ Profiles basic -jX functionality """ +# Copyright (c) 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2020 Frank Harrison <frank@doublethefish.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/checkers/unittest_base.py b/tests/checkers/unittest_base.py index f9d81ccf9..fbf66862e 100644 --- a/tests/checkers/unittest_base.py +++ b/tests/checkers/unittest_base.py @@ -1,18 +1,18 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2013-2014 Google, Inc. -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Dmitry Pribysh <dmand@yandex.ru> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Yannack <yannack@users.noreply.github.com> -# Copyright (c) 2017, 2019 Ville Skyttä <ville.skytta@iki.fi> # Copyright (c) 2017 Pierre Sassoulas <pierre.sassoulas@cea.fr> +# Copyright (c) 2017, 2019 Ville Skyttä <ville.skytta@iki.fi> # Copyright (c) 2017 ttenhoeve-aa <ttenhoeve@appannie.com> # Copyright (c) 2017 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2018 Fureigh <fureigh@users.noreply.github.com> # Copyright (c) 2018 glmdgrielson <32415403+glmdgrielson@users.noreply.github.com> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2020 bernie gray <bfgray3@users.noreply.github.com> diff --git a/tests/checkers/unittest_classes.py b/tests/checkers/unittest_classes.py index cb6e2227f..712e92d67 100644 --- a/tests/checkers/unittest_classes.py +++ b/tests/checkers/unittest_classes.py @@ -1,13 +1,13 @@ -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Bryce Guinta <bryce.paul.guinta@gmail.com> # Copyright (c) 2018 ssolanki <sushobhitsolanki@gmail.com> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 hippo91 <guillaume.peillex@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/checkers/unittest_exceptions.py b/tests/checkers/unittest_exceptions.py index eb4e2f379..5fec0e425 100644 --- a/tests/checkers/unittest_exceptions.py +++ b/tests/checkers/unittest_exceptions.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Rene Zhang <rz99@cornell.edu> # Copyright (c) 2015 Steven Myint <hg@stevenmyint.com> # Copyright (c) 2015 Pavel Roskin <proski@gnu.org> @@ -6,6 +6,7 @@ # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Brian Shaginaw <brian.shaginaw@warbyparker.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/checkers/unittest_format.py b/tests/checkers/unittest_format.py index 562649eb9..acb966ae8 100644 --- a/tests/checkers/unittest_format.py +++ b/tests/checkers/unittest_format.py @@ -2,7 +2,7 @@ # Copyright (c) 2009-2011, 2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> # Copyright (c) 2013-2014 Google, Inc. -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 buck <buck.2019@gmail.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Harut <yes@harutune.name> @@ -13,9 +13,9 @@ # Copyright (c) 2017 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2017 James M. Allen <james.m.allen@gmail.com> # Copyright (c) 2017 vinnyrose <vinnyrose@users.noreply.github.com> -# Copyright (c) 2018, 2020 Anthony Sottile <asottile@umich.edu> -# Copyright (c) 2018 Bryce Guinta <bryce.guinta@protonmail.com> +# Copyright (c) 2018, 2020 Bryce Guinta <bryce.guinta@protonmail.com> # Copyright (c) 2018 Bryce Guinta <bryce.paul.guinta@gmail.com> +# Copyright (c) 2018, 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> diff --git a/tests/checkers/unittest_imports.py b/tests/checkers/unittest_imports.py index f385fd2cd..8596f635c 100644 --- a/tests/checkers/unittest_imports.py +++ b/tests/checkers/unittest_imports.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Dmitry Pribysh <dmand@yandex.ru> # Copyright (c) 2015 Cezar <celnazli@bitdefender.com> # Copyright (c) 2015 James Morgensen <james.morgensen@gmail.com> @@ -7,9 +7,9 @@ # Copyright (c) 2018 Hornwitser <github@hornwitser.no> # Copyright (c) 2018 Marianna Polatoglou <mpolatoglou@bloomberg.net> # Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Nick Drozd <nicholasdrozd@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/checkers/unittest_logging.py b/tests/checkers/unittest_logging.py index 5eaa6c883..705b1fb8b 100644 --- a/tests/checkers/unittest_logging.py +++ b/tests/checkers/unittest_logging.py @@ -6,6 +6,7 @@ # Copyright (c) 2018 Alan Chan <achan961117@gmail.com> # Copyright (c) 2019-2020 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2019 Svet <svet@hyperscience.com> +# Copyright (c) 2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/checkers/unittest_misc.py b/tests/checkers/unittest_misc.py index 587bbd069..2ad917221 100644 --- a/tests/checkers/unittest_misc.py +++ b/tests/checkers/unittest_misc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2014, 2016-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2013-2014, 2016-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2013-2014 Google, Inc. # Copyright (c) 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> @@ -7,8 +7,8 @@ # Copyright (c) 2016 glegoux <gilles.legoux@gmail.com> # Copyright (c) 2018 Rogalski, Lukasz <lukasz.rogalski@intel.com> # Copyright (c) 2018 Anthony Sottile <asottile@umich.edu> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/checkers/unittest_python3.py b/tests/checkers/unittest_python3.py index fdb5b26fd..573e0271a 100644 --- a/tests/checkers/unittest_python3.py +++ b/tests/checkers/unittest_python3.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014-2015 Brett Cannon <brett@python.org> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2015 Cosmin Poieana <cmin@ropython.org> @@ -16,6 +16,7 @@ # Copyright (c) 2019 Gabriel R Sezefredo <gabriel@sezefredo.com.br> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Federico Bond <federicobond@gmail.com> # Copyright (c) 2020 Athos Ribeiro <athoscr@fedoraproject.org> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/checkers/unittest_similar.py b/tests/checkers/unittest_similar.py index 0fb438684..81e752780 100644 --- a/tests/checkers/unittest_similar.py +++ b/tests/checkers/unittest_similar.py @@ -2,7 +2,7 @@ # Copyright (c) 2012 Ry4an Brase <ry4an-hg@ry4an.org> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Scott Worley <scottworley@scottworley.com> # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> diff --git a/tests/checkers/unittest_spelling.py b/tests/checkers/unittest_spelling.py index 392df808b..8830f6a11 100644 --- a/tests/checkers/unittest_spelling.py +++ b/tests/checkers/unittest_spelling.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2017 Pedro Algarvio <pedro@algarvio.me> # Copyright (c) 2017 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2018, 2020 Anthony Sottile <asottile@umich.edu> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2019 agutole <toldo_carp@hotmail.com> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/checkers/unittest_stdlib.py b/tests/checkers/unittest_stdlib.py index 1331db709..72a9969b7 100644 --- a/tests/checkers/unittest_stdlib.py +++ b/tests/checkers/unittest_stdlib.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Cezar <celnazli@bitdefender.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2017 Martin <MartinBasti@users.noreply.github.com> diff --git a/tests/checkers/unittest_strings.py b/tests/checkers/unittest_strings.py index 2545f7b17..e5a496300 100644 --- a/tests/checkers/unittest_strings.py +++ b/tests/checkers/unittest_strings.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Lucas Cimon <lucas.cimon@gmail.com> # Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com> diff --git a/tests/checkers/unittest_typecheck.py b/tests/checkers/unittest_typecheck.py index 61d49d28f..e6f82efa9 100644 --- a/tests/checkers/unittest_typecheck.py +++ b/tests/checkers/unittest_typecheck.py @@ -2,7 +2,7 @@ # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Holger Peters <email@holger-peters.de> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Dmitry Pribysh <dmand@yandex.ru> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> @@ -14,6 +14,7 @@ # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2019 Martin Vielsmaier <martin.vielsmaier@gmail.com> # Copyright (c) 2019 Federico Bond <federicobond@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/checkers/unittest_utils.py b/tests/checkers/unittest_utils.py index 4da296bcf..5fee778b9 100644 --- a/tests/checkers/unittest_utils.py +++ b/tests/checkers/unittest_utils.py @@ -1,5 +1,5 @@ # Copyright (c) 2010 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> -# Copyright (c) 2013-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2013-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2013-2014 Google, Inc. # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> diff --git a/tests/checkers/unittest_variables.py b/tests/checkers/unittest_variables.py index 995138cb2..dac9e80f9 100644 --- a/tests/checkers/unittest_variables.py +++ b/tests/checkers/unittest_variables.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> @@ -10,6 +10,7 @@ # Copyright (c) 2018 mar-chi-pan <mar.polatoglou@gmail.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Andrew Simmons <anjsimmo@gmail.com> # Copyright (c) 2020 Andrew Simmons <a.simmons@deakin.edu.au> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/tests/extensions/test_bad_builtin.py b/tests/extensions/test_bad_builtin.py index a261c57fb..5ef80a02e 100644 --- a/tests/extensions/test_bad_builtin.py +++ b/tests/extensions/test_bad_builtin.py @@ -1,7 +1,8 @@ -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/extensions/test_broad_try_clause.py b/tests/extensions/test_broad_try_clause.py index 146f02b17..e392e29bb 100644 --- a/tests/extensions/test_broad_try_clause.py +++ b/tests/extensions/test_broad_try_clause.py @@ -1,6 +1,7 @@ +# Copyright (c) 2019-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2019-2020 Tyler Thieding <tyler@thieding.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/tests/extensions/test_check_docs.py b/tests/extensions/test_check_docs.py index c3af91c25..dfb5228de 100644 --- a/tests/extensions/test_check_docs.py +++ b/tests/extensions/test_check_docs.py @@ -1,5 +1,5 @@ # Copyright (c) 2014-2015 Bruno Daniel <bruno.daniel@blue-yonder.com> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> diff --git a/tests/extensions/test_check_docs_utils.py b/tests/extensions/test_check_docs_utils.py index 24555f292..9d234b581 100644 --- a/tests/extensions/test_check_docs_utils.py +++ b/tests/extensions/test_check_docs_utils.py @@ -1,9 +1,10 @@ +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016, 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/extensions/test_check_mccabe.py b/tests/extensions/test_check_mccabe.py index 25b812645..f852162d3 100644 --- a/tests/extensions/test_check_mccabe.py +++ b/tests/extensions/test_check_mccabe.py @@ -1,8 +1,9 @@ -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Moises Lopez <moylop260@vauxoo.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/extensions/test_check_raise_docs.py b/tests/extensions/test_check_raise_docs.py index c072dd51e..e4b1d6662 100644 --- a/tests/extensions/test_check_raise_docs.py +++ b/tests/extensions/test_check_raise_docs.py @@ -1,5 +1,5 @@ +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016, 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> # Copyright (c) 2018 Jim Robertson <jrobertson98atx@gmail.com> diff --git a/tests/extensions/test_check_return_docs.py b/tests/extensions/test_check_return_docs.py index bd871443a..7aee4500d 100644 --- a/tests/extensions/test_check_return_docs.py +++ b/tests/extensions/test_check_return_docs.py @@ -1,5 +1,5 @@ +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016, 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> # Copyright (c) 2016 Moises Lopez <moylop260@vauxoo.com> diff --git a/tests/extensions/test_check_yields_docs.py b/tests/extensions/test_check_yields_docs.py index b463dbb5f..0bb0b87ab 100644 --- a/tests/extensions/test_check_yields_docs.py +++ b/tests/extensions/test_check_yields_docs.py @@ -1,5 +1,5 @@ +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016, 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/tests/extensions/test_comparetozero.py b/tests/extensions/test_comparetozero.py index 661da3499..3ee1f978c 100644 --- a/tests/extensions/test_comparetozero.py +++ b/tests/extensions/test_comparetozero.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg> # Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com> -# Copyright (c) 2017-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/tests/extensions/test_docstyle.py b/tests/extensions/test_docstyle.py index 6c53d4419..131d2c838 100644 --- a/tests/extensions/test_docstyle.py +++ b/tests/extensions/test_docstyle.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2016 Luis Escobar <lescobar@vauxoo.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> diff --git a/tests/extensions/test_elseif_used.py b/tests/extensions/test_elseif_used.py index 57eda1429..c7f6ad1b6 100644 --- a/tests/extensions/test_elseif_used.py +++ b/tests/extensions/test_elseif_used.py @@ -1,8 +1,9 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/extensions/test_emptystring.py b/tests/extensions/test_emptystring.py index 9a9e25ea5..690a6f1c1 100644 --- a/tests/extensions/test_emptystring.py +++ b/tests/extensions/test_emptystring.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- # Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com> # Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg> -# Copyright (c) 2017-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/extensions/test_redefined.py b/tests/extensions/test_redefined.py index 98f9106a0..381a5a256 100644 --- a/tests/extensions/test_redefined.py +++ b/tests/extensions/test_redefined.py @@ -1,7 +1,8 @@ -# Copyright (c) 2016-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/functional/c/condition_evals_to_constant.py b/tests/functional/c/condition_evals_to_constant.py new file mode 100644 index 000000000..cfd0b00f4 --- /dev/null +++ b/tests/functional/c/condition_evals_to_constant.py @@ -0,0 +1,46 @@ +"""Test that boolean conditions simplify to a constant value""" +# pylint: disable=pointless-statement +from unknown import Unknown # pylint: disable=import-error + + +def func(_): + """Pointless function""" + + +CONSTANT = 100 +OTHER = 200 + +# Simplifies any boolean expression that is coerced into a True/False value +bool(CONSTANT or True) # [condition-evals-to-constant] +assert CONSTANT or True # [condition-evals-to-constant] +if CONSTANT and False: # [condition-evals-to-constant] + pass +elif CONSTANT and False: # [condition-evals-to-constant] + pass +while CONSTANT and False: # [condition-evals-to-constant] + break +1 if CONSTANT or True else 2 # [condition-evals-to-constant] +z = [x for x in range(10) if x or True] # [condition-evals-to-constant] + +# Simplifies recursively +assert True or CONSTANT or OTHER # [condition-evals-to-constant] +assert (CONSTANT or True) or (CONSTANT or True) # [condition-evals-to-constant] + +# Will try to infer the truthiness of an expression as long as it doesn't contain any variables +assert 3 + 4 or CONSTANT # [condition-evals-to-constant] +assert Unknown or True # [condition-evals-to-constant] + +assert True or True # [condition-evals-to-constant] +assert False or False # [condition-evals-to-constant] +assert True and True # [condition-evals-to-constant] +assert False and False # [condition-evals-to-constant] + + +# A bare constant that's not inside of a boolean operation will emit `using-constant-test` instead +if True: # pylint: disable=using-constant-test + pass + +# Expressions not in one of the above situations will not emit a message +CONSTANT or True +bool(CONSTANT or OTHER) +bool(func(CONSTANT or True)) diff --git a/tests/functional/c/condition_evals_to_constant.txt b/tests/functional/c/condition_evals_to_constant.txt new file mode 100644 index 000000000..5ff64887d --- /dev/null +++ b/tests/functional/c/condition_evals_to_constant.txt @@ -0,0 +1,15 @@ +condition-evals-to-constant:14::Boolean condition 'CONSTANT or True' will always evaluate to 'True' +condition-evals-to-constant:15::Boolean condition 'CONSTANT or True' will always evaluate to 'True' +condition-evals-to-constant:16::Boolean condition 'CONSTANT and False' will always evaluate to 'False' +condition-evals-to-constant:18::Boolean condition 'CONSTANT and False' will always evaluate to 'False' +condition-evals-to-constant:20::Boolean condition 'CONSTANT and False' will always evaluate to 'False' +condition-evals-to-constant:22::Boolean condition 'CONSTANT or True' will always evaluate to 'True' +condition-evals-to-constant:23::Boolean condition 'x or True' will always evaluate to 'True' +condition-evals-to-constant:26::Boolean condition 'True or CONSTANT or OTHER' will always evaluate to 'True' +condition-evals-to-constant:27::Boolean condition 'CONSTANT or True or CONSTANT or True' will always evaluate to 'True' +condition-evals-to-constant:30::Boolean condition '3 + 4 or CONSTANT' will always evaluate to '3 + 4' +condition-evals-to-constant:31::Boolean condition 'Unknown or True' will always evaluate to 'True' +condition-evals-to-constant:33::Boolean condition 'True or True' will always evaluate to 'True' +condition-evals-to-constant:34::Boolean condition 'False or False' will always evaluate to 'False' +condition-evals-to-constant:35::Boolean condition 'True and True' will always evaluate to 'True' +condition-evals-to-constant:36::Boolean condition 'False and False' will always evaluate to 'False' diff --git a/tests/functional/c/consider_merging_isinstance.py b/tests/functional/c/consider_merging_isinstance.py index 34068d9b7..d3387bd5c 100644 --- a/tests/functional/c/consider_merging_isinstance.py +++ b/tests/functional/c/consider_merging_isinstance.py @@ -1,5 +1,5 @@ """Checks use of consider-merging-isinstance""" -# pylint:disable=line-too-long +# pylint:disable=line-too-long, simplifiable-condition def isinstances(): diff --git a/tests/functional/l/len_checks.py b/tests/functional/l/len_checks.py index e8e61afad..216a7e672 100644 --- a/tests/functional/l/len_checks.py +++ b/tests/functional/l/len_checks.py @@ -1,5 +1,5 @@ # pylint: disable=too-few-public-methods,import-error, no-absolute-import,missing-docstring, misplaced-comparison-constant -# pylint: disable=useless-super-delegation,wrong-import-position,invalid-name, wrong-import-order +# pylint: disable=useless-super-delegation,wrong-import-position,invalid-name, wrong-import-order, condition-evals-to-constant if len('TEST'): # [len-as-condition] pass @@ -99,3 +99,6 @@ def github_issue_1331_v3(*args): def github_issue_1331_v4(*args): assert z and len(args), args # [len-as-condition] + +b = bool(len(z)) # [len-as-condition] +c = bool(len('TEST') or 42) # [len-as-condition] diff --git a/tests/functional/l/len_checks.txt b/tests/functional/l/len_checks.txt index 9dc2969f6..23e3f583f 100644 --- a/tests/functional/l/len_checks.txt +++ b/tests/functional/l/len_checks.txt @@ -11,3 +11,5 @@ len-as-condition:72::Do not use `len(SEQUENCE)` without comparison to determine len-as-condition:95:github_issue_1331_v2:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty len-as-condition:98:github_issue_1331_v3:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty len-as-condition:101:github_issue_1331_v4:Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty +len-as-condition:103::Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty +len-as-condition:104::Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty diff --git a/tests/functional/s/simplifiable_condition.py b/tests/functional/s/simplifiable_condition.py new file mode 100644 index 000000000..32bf36aca --- /dev/null +++ b/tests/functional/s/simplifiable_condition.py @@ -0,0 +1,36 @@ +"""Test that boolean conditions can be simplified""" +# pylint: disable=pointless-statement + + +def func(_): + """Pointless function""" + + +CONSTANT = 100 +OTHER = 200 + +# Simplifies any boolean expression that is coerced into a True/False value +bool(CONSTANT or False) # [simplifiable-condition] +assert CONSTANT or False # [simplifiable-condition] +if CONSTANT and True: # [simplifiable-condition] + pass +elif CONSTANT and True: # [simplifiable-condition] + pass +while CONSTANT and True: # [simplifiable-condition] + break +1 if CONSTANT or False else 2 # [simplifiable-condition] +z = [x for x in range(10) if x or False] # [simplifiable-condition] + +# Simplifies recursively +assert CONSTANT or (True and False) # [simplifiable-condition] +assert True and CONSTANT and OTHER # [simplifiable-condition] +assert (CONSTANT or False) and (OTHER or True) # [simplifiable-condition] + +# Will try to infer the truthiness of an expression as long as it doesn't contain any variables +assert [] or CONSTANT # [simplifiable-condition] +assert {} or CONSTANT # [simplifiable-condition] + +# Expressions not in one of the above situations will not emit a message +CONSTANT or True +bool(CONSTANT or OTHER) +bool(func(CONSTANT or True)) diff --git a/tests/functional/s/simplifiable_condition.txt b/tests/functional/s/simplifiable_condition.txt new file mode 100644 index 000000000..3649550c2 --- /dev/null +++ b/tests/functional/s/simplifiable_condition.txt @@ -0,0 +1,12 @@ +simplifiable-condition:13::Boolean condition 'CONSTANT or False' may be simplified to 'CONSTANT' +simplifiable-condition:14::Boolean condition 'CONSTANT or False' may be simplified to 'CONSTANT' +simplifiable-condition:15::Boolean condition 'CONSTANT and True' may be simplified to 'CONSTANT' +simplifiable-condition:17::Boolean condition 'CONSTANT and True' may be simplified to 'CONSTANT' +simplifiable-condition:19::Boolean condition 'CONSTANT and True' may be simplified to 'CONSTANT' +simplifiable-condition:21::Boolean condition 'CONSTANT or False' may be simplified to 'CONSTANT' +simplifiable-condition:22::Boolean condition 'x or False' may be simplified to 'x' +simplifiable-condition:25::Boolean condition 'CONSTANT or True and False' may be simplified to 'CONSTANT' +simplifiable-condition:26::Boolean condition 'True and CONSTANT and OTHER' may be simplified to 'CONSTANT and OTHER' +simplifiable-condition:27::Boolean condition '(CONSTANT or False) and (OTHER or True)' may be simplified to 'CONSTANT' +simplifiable-condition:30::Boolean condition '[] or CONSTANT' may be simplified to 'CONSTANT' +simplifiable-condition:31::Boolean condition '{} or CONSTANT' may be simplified to 'CONSTANT' diff --git a/tests/functional/too/too_many_boolean_expressions.py b/tests/functional/too/too_many_boolean_expressions.py index 68214ab8e..e8753859c 100644 --- a/tests/functional/too/too_many_boolean_expressions.py +++ b/tests/functional/too/too_many_boolean_expressions.py @@ -1,6 +1,6 @@ """Checks for if statements containing too many boolean expressions""" -# pylint: disable=invalid-name, comparison-with-itself, chained-comparison +# pylint: disable=invalid-name, comparison-with-itself, chained-comparison, condition-evals-to-constant x = y = z = 5 if x > -5 and x < 5 and y > -5 and y < 5 and z > -5 and z < 5: # [too-many-boolean-expressions] diff --git a/tests/functional/u/using_constant_test.py b/tests/functional/u/using_constant_test.py index d6624daa6..7e902e021 100644 --- a/tests/functional/u/using_constant_test.py +++ b/tests/functional/u/using_constant_test.py @@ -1,7 +1,7 @@ """Verify if constant tests are used inside if statements.""" # pylint: disable=invalid-name, missing-docstring,too-few-public-methods # pylint: disable=no-init,expression-not-assigned, useless-object-inheritance -# pylint: disable=missing-parentheses-for-call-in-test, unnecessary-comprehension +# pylint: disable=missing-parentheses-for-call-in-test, unnecessary-comprehension, condition-evals-to-constant import collections @@ -87,7 +87,6 @@ if Class.method: # [using-constant-test] if instance.method: # [using-constant-test] pass - # For these, we require to do inference, even though the result can be a # constant value. For some of them, we could determine that the test # is constant, such as 2 + 3, but the components of the BinOp diff --git a/tests/input/func_typecheck_callfunc_assigment.py b/tests/input/func_typecheck_callfunc_assigment.py index 36d476e89..e493014e2 100644 --- a/tests/input/func_typecheck_callfunc_assigment.py +++ b/tests/input/func_typecheck_callfunc_assigment.py @@ -1,4 +1,4 @@ -# pylint: disable=useless-return, useless-object-inheritance +# pylint: disable=useless-return, useless-object-inheritance, condition-evals-to-constant """check assignment to function call where the function doesn't return 'E1111': ('Assigning to function call which doesn\'t return', diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py index 380f80d43..4f047a25c 100644 --- a/tests/lint/unittest_lint.py +++ b/tests/lint/unittest_lint.py @@ -29,6 +29,7 @@ # Copyright (c) 2019 Trevor Bekolay <tbekolay@gmail.com> # Copyright (c) 2019 Andres Perez Hortal <andresperezcba@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/test_func.py b/tests/test_func.py index a349e3ffd..dd3a1bc63 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -1,7 +1,7 @@ # Copyright (c) 2006-2010, 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> # Copyright (c) 2013-2014 Google, Inc. -# Copyright (c) 2014-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Michal Nowikowski <godfryd@gmail.com> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> diff --git a/tests/test_functional.py b/tests/test_functional.py index f31221772..0b80628b6 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -12,6 +12,7 @@ # Copyright (c) 2019 Mr. Senko <atodorov@mrsenko.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Copyright (c) 2020 bernie gray <bfgray3@users.noreply.github.com> diff --git a/tests/test_import_graph.py b/tests/test_import_graph.py index 3abc4fd9c..0d4ea7f04 100644 --- a/tests/test_import_graph.py +++ b/tests/test_import_graph.py @@ -1,12 +1,13 @@ # Copyright (c) 2006-2008, 2010, 2013 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Reverb C <reverbc@users.noreply.github.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Frank Harrison <frank@doublethefish.com> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/test_regr.py b/tests/test_regr.py index 8ee871005..a26cc1be1 100644 --- a/tests/test_regr.py +++ b/tests/test_regr.py @@ -2,12 +2,13 @@ # Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Reverb C <reverbc@users.noreply.github.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/test_self.py b/tests/test_self.py index 999ec16a8..988c47d33 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -21,6 +21,7 @@ # Copyright (c) 2019 Hugues <hugues.bruant@affirm.com> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Pieter Engelbrecht <pengelbrecht@rems2.com> # Copyright (c) 2020 Clément Pit-Claudel <cpitclaudel@users.noreply.github.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> diff --git a/tests/unittest_config.py b/tests/unittest_config.py index db517c93b..c34546ade 100644 --- a/tests/unittest_config.py +++ b/tests/unittest_config.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Copyright (c) 2015 Aru Sahni <arusahni@gmail.com> -# Copyright (c) 2016-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2017 Ville Skyttä <ville.skytta@iki.fi> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/unittest_pyreverse_diadefs.py b/tests/unittest_pyreverse_diadefs.py index 6938a98cc..1d5326e7e 100644 --- a/tests/unittest_pyreverse_diadefs.py +++ b/tests/unittest_pyreverse_diadefs.py @@ -1,12 +1,13 @@ # Copyright (c) 2008-2010, 2013 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2019 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2018 Sushobhit <31987769+sushobhit27@users.noreply.github.com> # Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Copyright (c) 2020 Anthony Sottile <asottile@umich.edu> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/tests/unittest_pyreverse_inspector.py b/tests/unittest_pyreverse_inspector.py index 464b9d07e..a6bfe02ac 100644 --- a/tests/unittest_pyreverse_inspector.py +++ b/tests/unittest_pyreverse_inspector.py @@ -1,7 +1,8 @@ -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> +# Copyright (c) 2019-2020 Pierre Sassoulas <pierre.sassoulas@gmail.com> # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> -# Copyright (c) 2019 Pierre Sassoulas <pierre.sassoulas@gmail.com> +# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr> # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/master/COPYING diff --git a/tests/unittest_pyreverse_writer.py b/tests/unittest_pyreverse_writer.py index 3953fa4f8..814bf37d1 100644 --- a/tests/unittest_pyreverse_writer.py +++ b/tests/unittest_pyreverse_writer.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2008, 2010, 2013 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 Arun Persaud <arun@nubati.net> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> diff --git a/tests/unittest_reporters_json.py b/tests/unittest_reporters_json.py index fb61f2d72..4903316c9 100644 --- a/tests/unittest_reporters_json.py +++ b/tests/unittest_reporters_json.py @@ -1,5 +1,5 @@ # Copyright (c) 2014 Vlad Temian <vladtemian@gmail.com> -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> # Copyright (c) 2017 guillaume2 <guillaume.peillex@gmail.col> diff --git a/tests/unittest_reporting.py b/tests/unittest_reporting.py index e1aea46e8..7938a3f41 100644 --- a/tests/unittest_reporting.py +++ b/tests/unittest_reporting.py @@ -1,5 +1,5 @@ # Copyright (c) 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> -# Copyright (c) 2014-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2014-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2014 Calin Don <calin.don@gmail.com> # Copyright (c) 2014 Google, Inc. # Copyright (c) 2014 Arun Persaud <arun@nubati.net> diff --git a/tests/utils/unittest_utils.py b/tests/utils/unittest_utils.py index 98988c1f2..12b621b5b 100644 --- a/tests/utils/unittest_utils.py +++ b/tests/utils/unittest_utils.py @@ -2,7 +2,7 @@ # Copyright (c) 2013-2014 Google, Inc. # Copyright (c) 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr> # Copyright (c) 2014 Arun Persaud <arun@nubati.net> -# Copyright (c) 2015-2018 Claudiu Popa <pcmanticore@gmail.com> +# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com> # Copyright (c) 2015 Aru Sahni <arusahni@gmail.com> # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro> # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com> |