-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update cpplint.py for compatibility with Python 3 #797
Conversation
__xrange()__ was removed in Python 3 in favor of __range()__. This PR ensures similar functionality on both Python 2 and Python 3. Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (#21942) flake8 testing of https://github.com/nodejs/nan on Python 3.7.0 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` /home/travis/virtualenv/python3.7.0/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1 EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]') ./cpplint.py:1398:12: F821 undefined name 'xrange' for i in xrange(startpos, len(line)): ^ ./cpplint.py:1627:15: F821 undefined name 'xrange' for line in xrange(1, min(len(lines), 11)): ^ ./cpplint.py:1755:12: F821 undefined name 'xrange' for i in xrange(1, len(raw_lines) - 1): ^ ./cpplint.py:2096:14: F821 undefined name 'xrange' for i in xrange(linenum - 1, self.starting_linenum, -1): ^ ./cpplint.py:2882:26: F821 undefined name 'xrange' for start_linenum in xrange(linenum, clean_lines.NumLines()): ^ ./cpplint.py:3366:19: F821 undefined name 'xrange' for offset in xrange(endlinenum + 1, ^ ./cpplint.py:3537:14: F821 undefined name 'xrange' for i in xrange(start - 1, max(start - 6, 0), -1): ^ ./cpplint.py:3665:12: F821 undefined name 'xrange' for i in xrange(linenum, 0, -1): ^ ./cpplint.py:3670:16: F821 undefined name 'xrange' for j in xrange(linenum, clean_lines.NumLines(), 1): ^ ./cpplint.py:4233:14: F821 undefined name 'xrange' for i in xrange(linenum + 1, end_line): ^ ./cpplint.py:4361:23: F821 undefined name 'unicode' if isinstance(line, unicode): ^ ./cpplint.py:5011:12: F821 undefined name 'xrange' for i in xrange(linenum, max(-1, linenum - 10), -1): ^ ./cpplint.py:5032:12: F821 undefined name 'xrange' for i in xrange(linenum, max(-1, linenum - 10), -1): ^ ./cpplint.py:5048:12: F821 undefined name 'xrange' for i in xrange(linenum, 1, -1): ^ ./cpplint.py:5149:20: F821 undefined name 'xrange' for i in xrange(startline, linenum + 1): ^ ./cpplint.py:5173:14: F821 undefined name 'xrange' for i in xrange(linenum - 1, max(0, linenum - 10), -1): ^ ./cpplint.py:5204:14: F821 undefined name 'xrange' for i in xrange(2): ^ ./cpplint.py:5366:14: F821 undefined name 'xrange' for i in xrange(linenum - 1, max(0, linenum - 5), -1): ^ ./cpplint.py:5625:18: F821 undefined name 'xrange' for linenum in xrange(clean_lines.NumLines()): ^ ./cpplint.py:5781:21: F821 undefined name 'xrange' for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())): ^ ./cpplint.py:5796:12: F821 undefined name 'xrange' for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): ^ ./cpplint.py:6029:15: F821 undefined name 'xrange' for line in xrange(clean_lines.NumLines()): ^ 22 F821 undefined name 'xrange' 22 ```
Thanks for noticing. However, this file is just an old version redistributed from https://github.com/google/styleguide/tree/gh-pages/cpplint Can you change the description to something like "Update cpplint.py" and include the latest |
Thank you, this looks good to merge. |
__xrange()__ was removed in Python 3 in favor of __range()__. This PR ensures similar functionality on both Python 2 and Python 3. Similar to nodejs/nan#797 Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (nodejs/node#21942) flake8 testing of https://github.com/nodejs/node-chakracore on Python 3.7.0 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./tools/cpplint.py:1471:12: F821 undefined name 'xrange' for i in xrange(startpos, len(line)): ^ ./tools/cpplint.py:1700:15: F821 undefined name 'xrange' for line in xrange(1, min(len(lines), 11)): ^ ./tools/cpplint.py:1828:12: F821 undefined name 'xrange' for i in xrange(1, len(raw_lines) - 1): ^ ./tools/cpplint.py:2169:14: F821 undefined name 'xrange' for i in xrange(linenum - 1, self.starting_linenum, -1): ^ ./tools/cpplint.py:2950:26: F821 undefined name 'xrange' for start_linenum in xrange(linenum, clean_lines.NumLines()): ^ ./tools/cpplint.py:3437:14: F821 undefined name 'xrange' for i in xrange(first_line, last_line + 1, 1): ^ ./tools/cpplint.py:3501:19: F821 undefined name 'xrange' for offset in xrange(endlinenum + 1, ^ ./tools/cpplint.py:4047:14: F821 undefined name 'xrange' for i in xrange(linenum + 1, end_line): ^ ./tools/cpplint.py:4218:23: F821 undefined name 'unicode' if isinstance(line, unicode): ^ ./tools/cpplint.py:4870:12: F821 undefined name 'xrange' for i in xrange(linenum, max(-1, linenum - 10), -1): ^ ./tools/cpplint.py:4891:12: F821 undefined name 'xrange' for i in xrange(linenum, max(-1, linenum - 10), -1): ^ ./tools/cpplint.py:4907:12: F821 undefined name 'xrange' for i in xrange(linenum, 1, -1): ^ ./tools/cpplint.py:5008:20: F821 undefined name 'xrange' for i in xrange(startline, linenum + 1): ^ ./tools/cpplint.py:5032:14: F821 undefined name 'xrange' for i in xrange(linenum - 1, max(0, linenum - 10), -1): ^ ./tools/cpplint.py:5063:14: F821 undefined name 'xrange' for i in xrange(2): ^ ./tools/cpplint.py:5226:14: F821 undefined name 'xrange' for i in xrange(linenum - 1, max(0, linenum - 5), -1): ^ ./tools/cpplint.py:5442:18: F821 undefined name 'xrange' for linenum in xrange(clean_lines.NumLines()): ^ ./tools/cpplint.py:5573:21: F821 undefined name 'xrange' for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())): ^ ./tools/cpplint.py:5588:12: F821 undefined name 'xrange' for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): ^ ./tools/cpplint.py:5845:15: F821 undefined name 'xrange' for line in xrange(clean_lines.NumLines()): ^ ```
xrange() was removed in Python 3 in favor of range(). This PR ensures similar functionality on both Python 2 and Python 3.
Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (nodejs/node#21942)
flake8 testing of https://github.com/nodejs/nan on Python 3.7.0
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics