Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found by updated hacking version.

Remove hacking and friends from lower-constraints, they are not needed
there at all.

Change-Id: I35d848e9af297d3561ea2838a4808166d1c36601
This commit is contained in:
Andreas Jaeger 2020-03-31 21:19:04 +02:00 committed by Witold Bedyk
parent 949712d4fa
commit abad342eb2
15 changed files with 65 additions and 55 deletions

View File

@ -25,8 +25,8 @@ import sys
from oslo_utils.encodeutils import safe_decode
from oslo_utils.encodeutils import safe_encode
import six.moves.urllib.parse as urlparse
from six.moves import urllib
import six.moves.urllib.parse as urlparse
ADMIN = 'root'
ADMIN_PASS = 'root'
@ -77,7 +77,8 @@ def influxdb_get_post(uri, query, db=None):
"""Runs a query using HTTP GET or POST and returns the response as a Python list.
At some InfluxDB release several ops changed from using GET to POST. For example,
CREATE DATABASE. To maintain backward compatibility, this function first trys the
query using POST and if that fails it retries again using GET."""
query using POST and if that fails it retries again using GET.
"""
query_params = {"q": query}
if db:
@ -115,10 +116,12 @@ def main(argv=None):
query="SHOW RETENTION POLICIES ON {0}".format(DBNAME))
if not any(pol[0] == SHARDSPACE_NAME for pol in policies):
# Set retention policy
policy = "CREATE RETENTION POLICY {0} ON {1} DURATION {2} REPLICATION {3} DEFAULT".format(SHARDSPACE_NAME,
policy = ("CREATE RETENTION POLICY {0} ON {1} DURATION {2} "
"REPLICATION {3} DEFAULT".format(SHARDSPACE_NAME,
DBNAME,
RETENTION,
REPLICATION)
)
influxdb_get_post(uri=api_uri, db=DBNAME, query=policy)
# Create the users
@ -130,5 +133,6 @@ def main(argv=None):
.format(name, password)),
db=DBNAME)
if __name__ == "__main__":
sys.exit(main())

View File

@ -18,9 +18,9 @@
"""Health check will returns 0 when service is working properly."""
import logging
from urllib import request
import os
import sys
from urllib import request
LOG_LEVEL = logging.getLevelName(os.environ.get('LOG_LEVEL', 'INFO'))

View File

@ -22,7 +22,6 @@ extras==1.0.0
falcon==2.0.0
fasteners==0.7.0
fixtures==3.0.0
flake8==2.5.5
funcsigs==1.0.0
future==0.16.0
futures==3.0.0
@ -30,7 +29,6 @@ gevent==1.2.2
gitdb==0.6.4
GitPython==1.0.1
greenlet==0.4.10
hacking==1.1.0
httplib2==0.9.1
idna==2.6
imagesize==0.7.1
@ -72,13 +70,11 @@ paramiko==2.0.0
PasteDeploy==1.5.0
Paste==2.0.2
pbr==2.0.0
pep8==1.5.7
positional==1.2.1
prettytable==0.7.2
pyasn1==0.1.8
pycadf==1.1.0
pycparser==2.18
pyflakes==0.8.1
Pygments==2.2.0
pyinotify==0.9.6
PyMySQL==0.7.6

View File

@ -21,5 +21,6 @@ from monasca_api.api import server
def main():
return server.get_wsgi_app(config_base_path='/etc/monasca')
if __name__ == '__main__' or __name__.startswith('_mod_wsgi'):
application = main()

View File

@ -78,5 +78,6 @@ def run_migrations_online():
with context.begin_transaction():
context.run_migrations()
if have_context:
run_migrations_online()

View File

@ -221,6 +221,7 @@ def periodsValidation(instr, loc, tokens):
# Must return the string
return tokens[0]
# Initialize non-ascii unicode code points in the Basic Multilingual Plane.
unicode_printables = u''.join(
six.unichr(c) for c in range(128, 65536) if not six.unichr(c).isspace())

View File

@ -14,17 +14,15 @@
import re
from hacking import core
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
@core.flake8ext
def no_xrange(logical_line):
"""Do not use 'xrange'
B319
"""
if assert_no_xrange_re.match(logical_line):
yield (0, "B319: Do not use xrange().")
def factory(register):
register(no_xrange)

View File

@ -180,6 +180,7 @@ def _hex_to_unicode(hex_raw):
hex_str = hex_str_raw.decode('utf-8', 'replace')
return hex_str
# NOTE(trebskit) => http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
UNICODE_MESSAGES = [
# Unicode is evil...

View File

@ -103,7 +103,7 @@ class TestTimestampsValidation(base.BaseTestCase):
try:
helpers.validate_start_end_timestamps(start_timestamp,
end_timestamp)
except:
except Exception:
self.fail("shouldn't happen")
def test_same_timestamps(self):
@ -156,6 +156,7 @@ class TestConvertTimeString(base.BaseTestCase):
ValueError,
helpers._convert_time_string, date_time_string)
valid_periods = [0, 60]

View File

@ -59,6 +59,7 @@ def validate_alarm_action_list(v):
def validate_undetermined_action_list(v):
validate_action_list(v, 'UNDETERMINED')
alarm_definition_schema = {
Required('name'): All(Any(str, six.text_type), Length(max=255)),
Required('expression'): All(Any(str, six.text_type)),

View File

@ -4,7 +4,7 @@
# Hacking already pins down pep8, pyflakes and flake8
bandit>=1.1.0 # Apache-2.0
bashate>=0.5.1 # Apache-2.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
hacking>=3.0,<3.1.0 # Apache-2.0
Babel!=2.4.0,>=2.3.4 # BSD
coverage!=4.4,>=4.0 # Apache-2.0
cassandra-driver!=3.6.0,>=3.3.0 # Apache-2.0

View File

@ -144,7 +144,8 @@ commands = bindep test
# H201 no 'except:' at least use 'except Exception:'
# H302 import only modules
# H405 multi line docstring summary not separated with an empty line
ignore = F821,H201,H302,H405
# W504 line break after binary operator
ignore = F821,H201,H302,H405,W504
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality.
@ -161,6 +162,11 @@ local-check-factory = monasca_api.hacking.checks.factory
import_exceptions =
six.moves
[flake8:local-plugins]
extension =
B319 = checks:no_xrange
paths = ./monasca_api/hacking
[testenv:lower-constraints]
deps =
-c{toxinidir}/lower-constraints.txt