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 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 self.errors.append((node, 'A202 dead code after ' | 95 self.errors.append((node, 'A202 dead code after ' |
96 '{}'.format(statement))) | 96 '{}'.format(statement))) |
97 | 97 |
98 if isinstance(node, LEAVE_BLOCK): | 98 if isinstance(node, LEAVE_BLOCK): |
99 leave_node = node | 99 leave_node = node |
100 | 100 |
101 if can_have_unused_expr or not isinstance(node, ast.Expr): | 101 if can_have_unused_expr or not isinstance(node, ast.Expr): |
102 continue | 102 continue |
103 if docstring and i == 0 and isinstance(node.value, ast.Str): | 103 if docstring and i == 0 and isinstance(node.value, ast.Str): |
104 continue | 104 continue |
105 if isinstance(node.value, (ast.Call, ast.Yield)): | 105 |
| 106 non_literal_expr_nodes = (ast.Call, ast.Yield) |
| 107 try: |
| 108 non_literal_expr_nodes += (ast.YieldFrom,) |
| 109 except AttributeError: |
| 110 pass |
| 111 if isinstance(node.value, non_literal_expr_nodes): |
106 continue | 112 continue |
107 | 113 |
108 self.errors.append((node, 'A203 unused expression')) | 114 self.errors.append((node, 'A203 unused expression')) |
109 | 115 |
110 if pass_node: | 116 if pass_node: |
111 if not nodes_required or len(nodes) > 1: | 117 if not nodes_required or len(nodes) > 1: |
112 self.errors.append((pass_node, 'A204 redundant ' | 118 self.errors.append((pass_node, 'A204 redundant ' |
113 'pass statement')) | 119 'pass statement')) |
114 | 120 |
115 if not block_required and not has_non_pass: | 121 if not block_required and not has_non_pass: |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return [(pos, 'A111 redundant parenthesis for {} ' | 472 return [(pos, 'A111 redundant parenthesis for {} ' |
467 'statement'.format(statement))] | 473 'statement'.format(statement))] |
468 | 474 |
469 return [] | 475 return [] |
470 | 476 |
471 | 477 |
472 for checker in [check_ast, check_non_default_encoding, | 478 for checker in [check_ast, check_non_default_encoding, |
473 check_quotes, check_redundant_parenthesis]: | 479 check_quotes, check_redundant_parenthesis]: |
474 checker.name = 'eyeo' | 480 checker.name = 'eyeo' |
475 checker.version = __version__ | 481 checker.version = __version__ |
OLD | NEW |