Skip to content

Commit 0d31ef4

Browse files
committed
Enable W191 and W291 flake8 checks.
Remove trailing whitespace from Python files. Convert tabs to spaces.
1 parent 1c58250 commit 0d31ef4

13 files changed

+413
-411
lines changed

contrib/devtools/copyright_header.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def file_has_hashbang(file_lines):
506506

507507
def insert_python_header(filename, file_lines, start_year, end_year):
508508
if file_has_hashbang(file_lines):
509-
insert_idx = 1
509+
insert_idx = 1
510510
else:
511511
insert_idx = 0
512512
header_lines = get_python_header_lines_to_insert(start_year, end_year)
@@ -571,7 +571,7 @@ def insert_cmd(argv):
571571
if extension not in ['.h', '.cpp', '.cc', '.c', '.py']:
572572
sys.exit("*** cannot insert for file extension %s" % extension)
573573

574-
if extension == '.py':
574+
if extension == '.py':
575575
style = 'python'
576576
else:
577577
style = 'cpp'

contrib/devtools/lint-python.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
# F823 local variable name … referenced before assignment
6262
# F831 duplicate argument name in function definition
6363
# F841 local variable 'foo' is assigned to but never used
64+
# W191 indentation contains tabs
65+
# W291 trailing whitespace
6466
# W292 no newline at end of file
6567
# W293 blank line contains whitespace
6668
# W504 line break after binary operator
@@ -71,4 +73,4 @@
7173
# W605 invalid escape sequence "x"
7274
# W606 'async' and 'await' are reserved keywords starting with Python 3.7
7375

74-
flake8 --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
76+
flake8 --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 .

contrib/devtools/security-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def check_PE_DYNAMIC_BASE(executable):
150150
def check_PE_HIGH_ENTROPY_VA(executable):
151151
'''PIE: DllCharacteristics bit 0x20 signifies high-entropy ASLR'''
152152
(arch,bits) = get_PE_dll_characteristics(executable)
153-
if arch == 'i386:x86-64':
153+
if arch == 'i386:x86-64':
154154
reqbits = IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA
155155
else: # Unnecessary on 32-bit
156156
assert(arch == 'i386')

contrib/devtools/test-security-check.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def test_ELF(self):
3232
cc = 'gcc'
3333
write_testcode(source)
3434

35-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-zexecstack','-fno-stack-protector','-Wl,-znorelro']),
35+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-zexecstack','-fno-stack-protector','-Wl,-znorelro']),
3636
(1, executable+': failed PIE NX RELRO Canary'))
37-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fno-stack-protector','-Wl,-znorelro']),
37+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fno-stack-protector','-Wl,-znorelro']),
3838
(1, executable+': failed PIE RELRO Canary'))
39-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro']),
39+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro']),
4040
(1, executable+': failed PIE RELRO'))
41-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro','-pie','-fPIE']),
41+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro','-pie','-fPIE']),
4242
(1, executable+': failed RELRO'))
43-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE']),
43+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE']),
4444
(0, ''))
4545

4646
def test_32bit_PE(self):
@@ -49,11 +49,11 @@ def test_32bit_PE(self):
4949
cc = 'i686-w64-mingw32-gcc'
5050
write_testcode(source)
5151

52-
self.assertEqual(call_security_check(cc, source, executable, []),
52+
self.assertEqual(call_security_check(cc, source, executable, []),
5353
(1, executable+': failed DYNAMIC_BASE NX'))
54-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']),
54+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']),
5555
(1, executable+': failed DYNAMIC_BASE'))
56-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']),
56+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']),
5757
(0, ''))
5858
def test_64bit_PE(self):
5959
source = 'test1.c'

0 commit comments

Comments
 (0)