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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 prefixes, quote, text = match.groups() | 389 prefixes, quote, text = match.groups() |
390 prefixes = prefixes.lower() | 390 prefixes = prefixes.lower() |
391 | 391 |
392 if 'u' in prefixes: | 392 if 'u' in prefixes: |
393 yield (start, 'A112 use "from __future__ import ' | 393 yield (start, 'A112 use "from __future__ import ' |
394 'unicode_literals" instead of ' | 394 'unicode_literals" instead of ' |
395 'prefixing literals with "u"') | 395 'prefixing literals with "u"') |
396 | 396 |
397 if first_token and re.search(r'^(?:(?:def|class)\s|$)', | 397 if first_token and re.search(r'^(?:(?:def|class)\s|$)', |
398 previous_logical): | 398 previous_logical): |
399 if quote != '"""': | 399 pass # Ignore docstrings |
400 yield (start, 'A109 use triple double ' | |
401 'quotes for docstrings') | |
402 elif start[0] != end[0]: | 400 elif start[0] != end[0]: |
403 pass | 401 pass # Ignore multiline strings |
404 elif 'r' in prefixes: | 402 elif 'r' in prefixes: |
405 if quote != "'" and not (quote == '"' and "'" in text): | 403 if quote != "'" and not (quote == '"' and "'" in text): |
406 yield (start, 'A110 use single quotes for raw string') | 404 yield (start, 'A110 use single quotes for raw string') |
407 else: | 405 else: |
408 prefix = '' | 406 prefix = '' |
409 if sys.version_info[0] >= 3: | 407 if sys.version_info[0] >= 3: |
410 if 'b' in prefixes: | 408 if 'b' in prefixes: |
411 prefix = 'b' | 409 prefix = 'b' |
412 else: | 410 else: |
413 u_literals = checker_state.get('has_unicode_literals') | 411 u_literals = checker_state.get('has_unicode_literals') |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 return [(pos, 'A111 redundant parenthesis for {} ' | 468 return [(pos, 'A111 redundant parenthesis for {} ' |
471 'statement'.format(statement))] | 469 'statement'.format(statement))] |
472 | 470 |
473 return [] | 471 return [] |
474 | 472 |
475 | 473 |
476 for checker in [ASTChecker, check_non_default_encoding, | 474 for checker in [ASTChecker, check_non_default_encoding, |
477 check_quotes, check_redundant_parenthesis]: | 475 check_quotes, check_redundant_parenthesis]: |
478 checker.name = 'eyeo' | 476 checker.name = 'eyeo' |
479 checker.version = __version__ | 477 checker.version = __version__ |
OLD | NEW |