| OLD | NEW |
| 1 # This file is part of Adblock Plus <https://adblockplus.org/>, | 1 # This file is part of Adblock Plus <https://adblockplus.org/>, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
| 12 # | 12 # |
| 13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
| 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 |
| 16 import ast | 16 import ast |
| 17 import re | 17 import re |
| 18 import tokenize | 18 import tokenize |
| 19 import sys | 19 import sys |
| 20 import collections | 20 import collections |
| 21 | 21 |
| 22 try: | 22 try: |
| 23 import builtins | 23 import builtins |
| 24 except ImportError: | 24 except ImportError: |
| 25 import __builtin__ as builtins | 25 import __builtin__ as builtins |
| 26 | 26 |
| 27 import pkg_resources | 27 import pkg_resources |
| 28 import flake8 | |
| 29 | 28 |
| 30 try: | 29 try: |
| 31 ascii | 30 ascii |
| 32 except NameError: | 31 except NameError: |
| 33 ascii = repr | 32 ascii = repr |
| 34 | 33 |
| 35 __version__ = pkg_resources.get_distribution('flake8-eyeo').version | 34 __version__ = pkg_resources.get_distribution('flake8-eyeo').version |
| 36 | 35 |
| 37 DISCOURAGED_APIS = { | 36 DISCOURAGED_APIS = { |
| 38 're.match': 're.search', | 37 're.match': 're.search', |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 # outer parenthesis closed before end of expression | 467 # outer parenthesis closed before end of expression |
| 469 if tokens[i + 1][:2] != (tokenize.OP, ':'): | 468 if tokens[i + 1][:2] != (tokenize.OP, ':'): |
| 470 break | 469 break |
| 471 | 470 |
| 472 return [(pos, 'A111 redundant parenthesis for {} ' | 471 return [(pos, 'A111 redundant parenthesis for {} ' |
| 473 'statement'.format(statement))] | 472 'statement'.format(statement))] |
| 474 | 473 |
| 475 return [] | 474 return [] |
| 476 | 475 |
| 477 | 476 |
| 478 # With flake8 3, the way the entry points are register in setup.py, | 477 for checker in [ASTChecker, check_non_default_encoding, |
| 479 # they are recognized as a group, and the name and version is detected | 478 check_quotes, check_redundant_parenthesis]: |
| 480 # automatically. For compatibility with flake8 2, however, we need to | 479 checker.name = 'eyeo' |
| 481 # assign the name and version to each checker individually. | 480 checker.version = __version__ |
| 482 if int(flake8.__version__.split('.')[0]) < 3: | |
| 483 for checker in [ASTChecker, check_non_default_encoding, | |
| 484 check_quotes, check_redundant_parenthesis]: | |
| 485 checker.name = 'eyeo' | |
| 486 checker.version = __version__ | |
| OLD | NEW |