summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2018-12-05 17:47:14 +0000
committerAnthony Sottile <asottile@umich.edu>2018-12-05 17:47:14 +0000
commit9a9237a3386acb4a28b3eeb237e24cce973f17f6 (patch)
tree3bebd2170ee80db5ca7829156307fdcd006b9ddd /src
parent93ad9617b0a192836cbc9a591b5abe74e2c85ba7 (diff)
parent3216c7b362bfc6e86a9b342c0e364750a972a65e (diff)
downloadflake8-9a9237a3386acb4a28b3eeb237e24cce973f17f6.tar.gz
Merge branch 'old-py' into 'master'
Remove workarounds for older, unsupported Pythons See merge request pycqa/flake8!271
Diffstat (limited to 'src')
-rw-r--r--src/flake8/checker.py14
-rw-r--r--src/flake8/processor.py17
-rw-r--r--src/flake8/utils.py11
3 files changed, 5 insertions, 37 deletions
diff --git a/src/flake8/checker.py b/src/flake8/checker.py
index 3b97414..8b1655b 100644
--- a/src/flake8/checker.py
+++ b/src/flake8/checker.py
@@ -577,11 +577,6 @@ class FileChecker(object):
elif parens == 0:
if processor.token_is_newline(token):
self.handle_newline(token_type)
- elif (
- processor.token_is_comment(token)
- and len(file_processor.tokens) == 1
- ):
- self.handle_comment(token, text)
if file_processor.tokens:
# If any tokens are left over, process them
@@ -606,15 +601,6 @@ class FileChecker(object):
self.statistics["logical lines"] = logical_lines
return self.filename, self.results, self.statistics
- def handle_comment(self, token, token_text):
- """Handle the logic when encountering a comment token."""
- # The comment also ends a physical line
- token = list(token)
- token[1] = token_text.rstrip("\r\n")
- token[3] = (token[2][0], token[2][1] + len(token[1]))
- self.processor.tokens = [tuple(token)]
- self.run_logical_checks()
-
def handle_newline(self, token_type):
"""Handle the logic when encountering a newline token."""
if token_type == tokenize.NEWLINE:
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index 18f9f1d..692d9d4 100644
--- a/src/flake8/processor.py
+++ b/src/flake8/processor.py
@@ -12,9 +12,6 @@ from flake8 import utils
LOG = logging.getLogger(__name__)
PyCF_ONLY_AST = 1024
NEWLINE = frozenset([tokenize.NL, tokenize.NEWLINE])
-# 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"
SKIP_TOKENS = frozenset(
[tokenize.NL, tokenize.NEWLINE, tokenize.INDENT, tokenize.DEDENT]
@@ -373,15 +370,6 @@ def is_eol_token(token):
return token[0] in NEWLINE or token[4][token[3][1] :].lstrip() == "\\\n"
-if COMMENT_WITH_NL: # If on Python 2.6
-
- def is_eol_token(token, _is_eol_token=is_eol_token):
- """Check if the token is an end-of-line token."""
- return _is_eol_token(token) or (
- token[0] == tokenize.COMMENT and token[1] == token[4]
- )
-
-
def is_multiline_string(token):
"""Check if this is a multiline string."""
return token[0] == tokenize.STRING and "\n" in token[1]
@@ -392,11 +380,6 @@ def token_is_newline(token):
return token[0] in NEWLINE
-def token_is_comment(token):
- """Check if the token type is a comment."""
- return COMMENT_WITH_NL and token[0] == tokenize.COMMENT
-
-
def count_parentheses(current_parentheses_count, token_text):
"""Count the number of parentheses."""
current_parentheses_count = current_parentheses_count or 0
diff --git a/src/flake8/utils.py b/src/flake8/utils.py
index 68627af..e5eef45 100644
--- a/src/flake8/utils.py
+++ b/src/flake8/utils.py
@@ -376,9 +376,8 @@ def get_python_version():
:rtype:
str
"""
- # The implementation isn't all that important.
- try:
- impl = platform.python_implementation() + " "
- except AttributeError: # Python 2.5
- impl = ""
- return "%s%s on %s" % (impl, platform.python_version(), platform.system())
+ return "%s %s on %s" % (
+ platform.python_implementation(),
+ platform.python_version(),
+ platform.system(),
+ )