Skip to content
This repository was archived by the owner on Jul 13, 2019. It is now read-only.

Commit b066038

Browse files
committed
Make pyflakes pass
1 parent 35510a5 commit b066038

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

.travis.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ language: python
44
sudo: false
55

66
python:
7-
- "3.4"
8-
- "3.3"
9-
- "3.2"
10-
- "2.7"
11-
- "2.6"
7+
- 3.5
8+
- 3.4
9+
- 3.3
10+
- 3.2
11+
- 2.7
12+
- 2.6
13+
- pypy
14+
- pypy3
15+
install:
16+
- pip install pyflakes
1217
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
1318
# install: "sudo apt-get install"
1419
# command to run tests, e.g. python setup.py test
15-
script: python cpplint_unittest.py
20+
script:
21+
- python cpplint_unittest.py
22+
- pyflakes cpplint.py
23+
- pyflakes cpplint_unittest.py

cpplint.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,20 +502,26 @@
502502
# This is set by --linelength flag.
503503
_line_length = 80
504504

505+
try:
506+
xrange
507+
except NameError:
508+
xrange = range
509+
510+
try:
511+
unicode
512+
except NameError:
513+
basestring = unicode = str
514+
505515
if sys.version_info < (3,):
506516
def u(x):
507517
return codecs.unicode_escape_decode(x)[0]
508-
TEXT_TYPE = unicode
509518
# BINARY_TYPE = str
510-
range = xrange
511519
itervalues = dict.itervalues
512520
iteritems = dict.iteritems
513521
else:
514522
def u(x):
515523
return x
516-
TEXT_TYPE = str
517524
# BINARY_TYPE = bytes
518-
xrange = range
519525
itervalues = dict.values
520526
iteritems = dict.items
521527

@@ -4380,7 +4386,7 @@ def GetLineWidth(line):
43804386
The width of the line in column positions, accounting for Unicode
43814387
combining characters and wide characters.
43824388
"""
4383-
if isinstance(line, TEXT_TYPE):
4389+
if isinstance(line, unicode):
43844390
width = 0
43854391
for uc in unicodedata.normalize('NFC', line):
43864392
if unicodedata.east_asian_width(uc) in ('W', 'F'):
@@ -4817,9 +4823,6 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
48174823
if match:
48184824
include_state.ResetSection(match.group(1))
48194825

4820-
# Make Windows paths like Unix.
4821-
fullname = os.path.abspath(filename).replace('\\', '/')
4822-
48234826
# Perform other checks now that we are sure that this is not an include line
48244827
CheckCasts(filename, clean_lines, linenum, error)
48254828
CheckGlobalStatic(filename, clean_lines, linenum, error)

cpplint_unittest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,22 @@
4444

4545
import cpplint
4646

47+
try:
48+
xrange
49+
except NameError:
50+
xrange = range
51+
52+
try:
53+
unicode
54+
except NameError:
55+
basestring = unicode = str
56+
4757
if sys.version_info < (3,):
48-
range = xrange
4958
def u(x):
5059
return codecs.unicode_escape_decode(x)[0]
5160
def b(x):
5261
return x
5362
else:
54-
xrange = range
5563
def u(x):
5664
return x
5765
def b(x):

0 commit comments

Comments
 (0)