summaryrefslogtreecommitdiff
path: root/pycodestyle.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-01-16 17:37:40 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2018-06-02 08:45:53 -0700
commit06900154096902ebbd8076b4ff22a4f41327626d (patch)
tree3b11bf8cd36fc7d48069f85f7481e4a1afc23d98 /pycodestyle.py
parent036461879fbfdb4ddbb689163e968d7f00ded66f (diff)
downloadpep8-06900154096902ebbd8076b4ff22a4f41327626d.tar.gz
Remove support for EOL Python 2.6 and 3.3
Python 2.6 an 3.3 are end of life. They are no longer receiving bug fixes, including for security issues. Python 2.6 went EOL on 2013-10-29 and 3.3 on 2017-09-29. For additional details on support Python versions, see: https://devguide.python.org/#status-of-python-branches Removing support for EOL Pythons will reduce testing and maintenance resources. Removed all workarounds for older Pythons. Updated trove classifiers and documentation to better communicate supported Python versions. Additionally, pass python_requires argument to setuptools. Helps pip decide what version of the library to install. https://packaging.python.org/tutorials/distributing-packages/#python-requires > If your project only runs on certain Python versions, setting the > python_requires argument to the appropriate PEP 440 version specifier > string will prevent pip from installing the project on other Python > versions. https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords > python_requires > > A string corresponding to a version specifier (as defined in PEP 440) > for the Python version, used to specify the Requires-Python defined in > PEP 345. Can now use more modern Python syntax including dictionary comprehension as well as more generators. Closes #755
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-xpycodestyle.py35
1 files changed, 9 insertions, 26 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index 50149f1..bcf9933 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -156,11 +156,6 @@ STARTSWITH_INDENT_STATEMENT_REGEX = re.compile(
)
DUNDER_REGEX = re.compile(r'^__([^\s]+)__ = ')
-# 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'
-
-
_checks = {'physical_line': {}, 'logical_line': {}, 'tree': {}}
@@ -1118,7 +1113,7 @@ def compound_statements(logical_line):
last_char = len(line) - 1
found = line.find(':')
prev_found = 0
- counts = dict((char, 0) for char in '{}[]()')
+ counts = {char: 0 for char in '{}[]()'}
while -1 < found < last_char:
update_counts(line[prev_found:found], counts)
if ((counts['{'] <= counts['}'] and # {'a': 1} (dict)
@@ -1762,9 +1757,11 @@ def parse_udiff(diff, patterns=None, parent='.'):
if path[:2] in ('b/', 'w/', 'i/'):
path = path[2:]
rv[path] = set()
- return dict([(os.path.join(parent, filepath), rows)
- for (filepath, rows) in rv.items()
- if rows and filename_match(filepath, patterns)])
+ return {
+ os.path.join(parent, filepath): rows
+ for (filepath, rows) in rv.items()
+ if rows and filename_match(filepath, patterns)
+ }
def normalize_paths(value, parent=os.curdir):
@@ -1807,11 +1804,6 @@ def _is_eol_token(token):
return token[0] in NEWLINE or token[4][token[3][1]:].lstrip() == '\\\n'
-if COMMENT_WITH_NL:
- def _is_eol_token(token, _eol_token=_is_eol_token):
- return _eol_token(token) or (token[0] == tokenize.COMMENT and
- token[1] == token[4])
-
########################################################################
# Framework to run all checks
########################################################################
@@ -2079,14 +2071,6 @@ class Checker(object):
del self.tokens[0]
else:
self.check_logical()
- elif COMMENT_WITH_NL and token_type == tokenize.COMMENT:
- if len(self.tokens) == 1:
- # The comment also ends a physical line
- token = list(token)
- token[1] = text.rstrip('\r\n')
- token[3] = (token[2][0], token[2][1] + len(token[1]))
- self.tokens = [tuple(token)]
- self.check_logical()
if self.tokens:
self.check_physical(self.lines[-1])
self.check_logical()
@@ -2154,8 +2138,8 @@ class BaseReport(object):
def get_count(self, prefix=''):
"""Return the total count of errors and warnings."""
- return sum([self.counters[key]
- for key in self.messages if key.startswith(prefix)])
+ return sum(self.counters[key]
+ for key in self.messages if key.startswith(prefix))
def get_statistics(self, prefix=''):
"""Get statistics for message codes that start with the prefix.
@@ -2503,8 +2487,7 @@ def read_config(options, args, arglist, parser):
warnings.warn('[pep8] section is deprecated. Use [pycodestyle].')
if pycodestyle_section:
- option_list = dict([(o.dest, o.type or o.action)
- for o in parser.option_list])
+ option_list = {o.dest: o.type or o.action for o in parser.option_list}
# First, read the default values
(new_options, __) = parser.parse_args([])