summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-06-17 01:45:22 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-06-17 01:45:22 +0200
commitaf843f1c5432fbfeb70c43188166af1a99834a02 (patch)
treebcbca3ea721d611f7f449722a0b4daec01e266b0
parentad664c12f7cbc2b2a8f1f847b6cfd727efc7b0fc (diff)
downloadpep8-af843f1c5432fbfeb70c43188166af1a99834a02.tar.gz
Regroup the sets of operators and other constants before the regular expressions.
-rwxr-xr-xpep8.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/pep8.py b/pep8.py
index 2b64801..95c50f7 100755
--- a/pep8.py
+++ b/pep8.py
@@ -124,6 +124,16 @@ REPORT_FORMAT = {
SINGLETONS = frozenset(['False', 'None', 'True'])
KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS
+BINARY_OPERATORS = frozenset([
+ '**=', '*=', '+=', '-=', '!=', '<>',
+ '%=', '^=', '&=', '|=', '==', '/=', '//=', '<=', '>=', '<<=', '>>=',
+ '%', '^', '&', '|', '=', '/', '//', '<', '>', '<<'])
+UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
+OPERATORS = BINARY_OPERATORS | UNARY_OPERATORS
+WHITESPACE = frozenset(' \t')
+SKIP_TOKENS = frozenset([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE,
+ tokenize.INDENT, tokenize.DEDENT])
+BENCHMARK_KEYS = ['directories', 'files', 'logical lines', 'physical lines']
INDENT_REGEX = re.compile(r'([ \t]*)')
RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*(,)')
@@ -142,17 +152,6 @@ OPERATOR_REGEX = re.compile(r'(?:[^\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)')
LAMBDA_REGEX = re.compile(r'\blambda\b')
HUNK_REGEX = re.compile(r'^@@ -\d+,\d+ \+(\d+),(\d+) @@.*$')
-WHITESPACE = frozenset(' \t')
-BINARY_OPERATORS = frozenset([
- '**=', '*=', '+=', '-=', '!=', '<>',
- '%=', '^=', '&=', '|=', '==', '/=', '//=', '<=', '>=', '<<=', '>>=',
- '%', '^', '&', '|', '=', '/', '//', '<', '>', '<<'])
-UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
-OPERATORS = BINARY_OPERATORS | UNARY_OPERATORS
-SKIP_TOKENS = frozenset([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE,
- tokenize.INDENT, tokenize.DEDENT])
-BENCHMARK_KEYS = ['directories', 'files', 'logical lines', 'physical lines']
-
# Work around Python < 2.6 behaviour, which does not generate NL after
# a comment which is on a line by itself.
COMMENT_WITH_NL = tokenize.generate_tokens(['#\n'].pop).send(None)[1] == '#\n'