Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: flake8-eyeo/flake8_eyeo.py

Issue 29573036: Noissue - Drop support for flake8 2 from flake8-eyeo (Closed)
Patch Set: Created Oct. 10, 2017, 8:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | flake8-eyeo/setup.py » ('j') | flake8-eyeo/setup.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 keys.append(key) 347 keys.append(key)
348 348
349 def visit_Dict(self, node): 349 def visit_Dict(self, node):
350 self._visit_hash_keys(node.keys, 'key in dict') 350 self._visit_hash_keys(node.keys, 'key in dict')
351 351
352 def visit_Set(self, node): 352 def visit_Set(self, node):
353 self._visit_hash_keys(node.elts, 'item in set') 353 self._visit_hash_keys(node.elts, 'item in set')
354 354
355 355
356 class ASTChecker(object): 356 def check_ast(tree):
Sebastian Noack 2017/10/10 20:15:32 This was merely a class because flake8 2 required
357 def __init__(self, tree, filename): 357 visitor = TreeVisitor()
358 self.tree = tree 358 visitor.visit(tree)
359 359
360 def run(self): 360 for node, error in visitor.errors:
361 visitor = TreeVisitor() 361 yield (node.lineno, node.col_offset, error, None)
Sebastian Noack 2017/10/10 20:15:32 The forth argument is obsolete and unused. However
362 visitor.visit(self.tree)
363
364 for node, error in visitor.errors:
365 yield (node.lineno, node.col_offset, error, type(self))
366 362
367 363
368 def check_non_default_encoding(physical_line, line_number): 364 def check_non_default_encoding(physical_line, line_number):
369 if line_number <= 2 and re.search(r'^\s*#.*coding[:=]', physical_line): 365 if line_number <= 2 and re.search(r'^\s*#.*coding[:=]', physical_line):
370 return (0, 'A303 non-default file encoding') 366 return (0, 'A303 non-default file encoding')
371 367
372 368
373 def check_quotes(logical_line, tokens, previous_logical, checker_state): 369 def check_quotes(logical_line, tokens, previous_logical, checker_state):
374 first_token = True 370 first_token = True
375 371
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 # outer parenthesis closed before end of expression 460 # outer parenthesis closed before end of expression
465 if tokens[i + 1][:2] != (tokenize.OP, ':'): 461 if tokens[i + 1][:2] != (tokenize.OP, ':'):
466 break 462 break
467 463
468 return [(pos, 'A111 redundant parenthesis for {} ' 464 return [(pos, 'A111 redundant parenthesis for {} '
469 'statement'.format(statement))] 465 'statement'.format(statement))]
470 466
471 return [] 467 return []
472 468
473 469
474 for checker in [ASTChecker, check_non_default_encoding, 470 for checker in [check_ast, check_non_default_encoding,
475 check_quotes, check_redundant_parenthesis]: 471 check_quotes, check_redundant_parenthesis]:
476 checker.name = 'eyeo' 472 checker.name = 'eyeo'
477 checker.version = __version__ 473 checker.version = __version__
OLDNEW
« no previous file with comments | « no previous file | flake8-eyeo/setup.py » ('j') | flake8-eyeo/setup.py » ('J')

Powered by Google App Engine
This is Rietveld