Merge "Bump hacking"
This commit is contained in:
commit
097ffc6df1
@ -15,6 +15,7 @@
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
@ -39,7 +40,7 @@ class Zone:
|
||||
self.to_file(sys.stdout)
|
||||
|
||||
def to_file(self, f):
|
||||
if type(f) == 'file':
|
||||
if isinstance(f, io.IOBase):
|
||||
fd = f
|
||||
elif type(f) is str:
|
||||
if os.path.isdir(f):
|
||||
|
@ -15,7 +15,6 @@
|
||||
import re
|
||||
|
||||
from hacking import core
|
||||
import pycodestyle
|
||||
|
||||
# D701: Default parameter value is a mutable type
|
||||
# D702: Log messages require translation
|
||||
@ -49,8 +48,8 @@ no_line_continuation_backslash_re = re.compile(r'.*(\\)\n')
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def mutable_default_arguments(physical_line, logical_line, filename):
|
||||
if pycodestyle.noqa(physical_line):
|
||||
def mutable_default_arguments(logical_line, filename, noqa):
|
||||
if noqa:
|
||||
return
|
||||
|
||||
if mutable_default_argument_check.match(logical_line):
|
||||
|
@ -1,10 +1,6 @@
|
||||
# Requirements lower bounds listed here are our best effort to keep them up to
|
||||
# date but we do not test them so no guarantee of having them all correct. If
|
||||
# you find any incorrect lower bounds, let us know or propose a fix.
|
||||
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
alembic>=1.8.0 # MIT
|
||||
eventlet>=0.26.1 # MIT
|
||||
Flask!=0.11,>=0.10 # BSD
|
||||
|
@ -1,9 +1,5 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking>=4.1.0,<4.2.0 # Apache-2.0
|
||||
hacking>=6.1.0,<6.2.0 # Apache-2.0
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
|
@ -1,90 +0,0 @@
|
||||
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
import sys
|
||||
import linecache
|
||||
|
||||
from prettytable import PrettyTable
|
||||
|
||||
PEP8_LINE = r'^((?P<file>.*):(?P<line>\d*):(?P<col>\d*):) ' \
|
||||
r'(?P<error>(?P<error_code>\w\d{1,3})(?P<error_desc>.*$))'
|
||||
|
||||
HTML = True
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
raw_errors = []
|
||||
|
||||
max_filename_len = 0
|
||||
for line in sys.stdin:
|
||||
m = re.match(PEP8_LINE, line)
|
||||
if m:
|
||||
m = m.groupdict()
|
||||
raw_errors.append(m)
|
||||
if len(m['file']) > max_filename_len:
|
||||
max_filename_len = len(m['file'])
|
||||
else:
|
||||
print(line)
|
||||
|
||||
if len(raw_errors) > 0:
|
||||
|
||||
print('Flake8 Results')
|
||||
|
||||
ct = PrettyTable([
|
||||
"File",
|
||||
"Line",
|
||||
"Column",
|
||||
"Error Code",
|
||||
"Error Message",
|
||||
"Code"
|
||||
])
|
||||
|
||||
ct.align["File"] = "l"
|
||||
ct.align["Error Message"] = "l"
|
||||
ct.align["Code"] = "l"
|
||||
|
||||
for line in raw_errors:
|
||||
ct.add_row(format_dict(line))
|
||||
|
||||
print(ct)
|
||||
|
||||
with open('flake8_results.html', 'w') as f:
|
||||
f.write('<html><head><style type="text/css">table a:link{color:#666;font-weight:700;text-decoration:none}table a:visited{color:#999;font-weight:700;text-decoration:none}table a:active,table a:hover{color:#bd5a35;text-decoration:underline}table{font-family:Arial,Helvetica,sans-serif;color:#666;font-size:12px;text-shadow:1px 1px 0 #fff;background:#eaebec;margin:20px;border:1px solid #ccc;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;-moz-box-shadow:0 1px 2px #d1d1d1;-webkit-box-shadow:0 1px 2px #d1d1d1;box-shadow:0 1px 2px #d1d1d1}table th{padding:21px 25px 22px;border-top:1px solid #fafafa;border-bottom:1px solid #e0e0e0;background:#ededed;background:-webkit-gradient(linear,left top,left bottom,from(#ededed),to(#ebebeb));background:-moz-linear-gradient(top,#ededed,#ebebeb)}table th:first-child{text-align:left;padding-left:20px}table tr:first-child th:first-child{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px}table tr:first-child th:last-child{-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px}table tr{text-align:left;padding-left:20px}table td:first-child{text-align:left;padding-left:20px;border-left:0}table td{padding:18px;border-top:1px solid #fff;border-bottom:1px solid #e0e0e0;border-left:1px solid #e0e0e0;background:#fafafa;background:-webkit-gradient(linear,left top,left bottom,from(#fbfbfb),to(#fafafa));background:-moz-linear-gradient(top,#fbfbfb,#fafafa)}table tr.even td{background:#f6f6f6;background:-webkit-gradient(linear,left top,left bottom,from(#f8f8f8),to(#f6f6f6));background:-moz-linear-gradient(top,#f8f8f8,#f6f6f6)}table tr:last-child td{border-bottom:0}table tr:last-child td:first-child{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px}table tr:last-child td:last-child{-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}table tr:hover td{background:#f2f2f2;background:-webkit-gradient(linear,left top,left bottom,from(#f2f2f2),to(#f0f0f0));background:-moz-linear-gradient(top,#f2f2f2,#f0f0f0)}</style></head><body>%s</body</html>' % ct.get_html_string(attributes = {"cellspacing": 0})) # noqa
|
||||
|
||||
|
||||
def format_dict(raw):
|
||||
output = []
|
||||
if raw['file'].startswith('./'):
|
||||
output.append(raw['file'][2:])
|
||||
else:
|
||||
output.append(raw['file'])
|
||||
|
||||
output.append(raw['line'])
|
||||
output.append(raw['col'])
|
||||
output.append(raw['error_code'])
|
||||
|
||||
output.append(raw['error_desc'].lstrip())
|
||||
|
||||
code_string = linecache.getline(
|
||||
output[0],
|
||||
int(raw['line'])).lstrip().rstrip()
|
||||
|
||||
output.append(code_string)
|
||||
|
||||
return output
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
TESTARGS=$1
|
||||
|
||||
exec 3>&1
|
||||
status=$(exec 4>&1 >&3; ( flake8 ; echo $? >&4 ) | python tools/pretty_flake8.py) && exit $status
|
6
tox.ini
6
tox.ini
@ -82,12 +82,14 @@ commands = oslo_debug_helper -t designate/tests {posargs}
|
||||
|
||||
[testenv:flake8]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = sh tools/pretty_flake8.sh
|
||||
commands =
|
||||
flake8
|
||||
{[testenv:bandit]commands}
|
||||
|
||||
[testenv:pep8]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = sh tools/pretty_flake8.sh
|
||||
commands =
|
||||
flake8
|
||||
{[testenv:bandit]commands}
|
||||
doc8 {posargs}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user