Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Update local hacking checks for new flake8. Remove hacking and friends from lower-constraints, it's not needed there. Change-Id: Iadf750a1e6d3181b645ceccdf75cf910bc23adfd
This commit is contained in:
parent
dc8956d7b8
commit
b306576d27
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""health check for Monasca-persister"""
|
"""health check for Monasca-persister"""
|
||||||
#TODO wait for health check endpoint ...
|
# TODO(Christian Brandstetter) wait for health check endpoint ...
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -8,13 +8,11 @@ docutils==0.11
|
|||||||
elasticsearch==2.0.0
|
elasticsearch==2.0.0
|
||||||
extras==1.0.0
|
extras==1.0.0
|
||||||
fixtures==3.0.0
|
fixtures==3.0.0
|
||||||
flake8==2.5.5
|
|
||||||
future==0.16.0
|
future==0.16.0
|
||||||
gevent==1.2.2
|
gevent==1.2.2
|
||||||
gitdb==0.6.4
|
gitdb==0.6.4
|
||||||
GitPython==1.0.1
|
GitPython==1.0.1
|
||||||
greenlet==0.4.10
|
greenlet==0.4.10
|
||||||
hacking==0.12.0
|
|
||||||
influxdb==2.9.2
|
influxdb==2.9.2
|
||||||
iso8601==0.1.11
|
iso8601==0.1.11
|
||||||
kazoo==2.2
|
kazoo==2.2
|
||||||
@ -40,8 +38,6 @@ oslo.serialization==2.18.0
|
|||||||
oslo.utils==3.33.0
|
oslo.utils==3.33.0
|
||||||
oslotest==3.2.0
|
oslotest==3.2.0
|
||||||
pbr==2.0.0
|
pbr==2.0.0
|
||||||
pep8==1.7.1
|
|
||||||
pyflakes==1.0.0
|
|
||||||
pyinotify==0.9.6
|
pyinotify==0.9.6
|
||||||
PyMySQL==0.7.6
|
PyMySQL==0.7.6
|
||||||
pyparsing==2.1.0
|
pyparsing==2.1.0
|
||||||
|
@ -11,8 +11,12 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from hacking import core
|
||||||
|
|
||||||
|
|
||||||
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
|
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
|
||||||
assert_True = re.compile(r".*assertEqual\(True, .*\)")
|
assert_True = re.compile(r".*assertEqual\(True, .*\)")
|
||||||
assert_None = re.compile(r".*assertEqual\(None, .*\)")
|
assert_None = re.compile(r".*assertEqual\(None, .*\)")
|
||||||
@ -23,17 +27,20 @@ no_log_warn = re.compile(r".*LOG.warn\(.*\)")
|
|||||||
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
|
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def no_mutable_default_args(logical_line):
|
def no_mutable_default_args(logical_line):
|
||||||
msg = "M001: Method's default argument shouldn't be mutable!"
|
msg = "M001: Method's default argument shouldn't be mutable!"
|
||||||
if mutable_default_args.match(logical_line):
|
if mutable_default_args.match(logical_line):
|
||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def no_xrange(logical_line):
|
def no_xrange(logical_line):
|
||||||
if assert_no_xrange_re.match(logical_line):
|
if assert_no_xrange_re.match(logical_line):
|
||||||
yield (0, "M002: Do not use xrange().")
|
yield (0, "M002: Do not use xrange().")
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def validate_assertTrue(logical_line):
|
def validate_assertTrue(logical_line):
|
||||||
if re.match(assert_True, logical_line):
|
if re.match(assert_True, logical_line):
|
||||||
msg = ("M003: Unit tests should use assertTrue(value) instead"
|
msg = ("M003: Unit tests should use assertTrue(value) instead"
|
||||||
@ -41,6 +48,7 @@ def validate_assertTrue(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def validate_assertIsNone(logical_line):
|
def validate_assertIsNone(logical_line):
|
||||||
if re.match(assert_None, logical_line):
|
if re.match(assert_None, logical_line):
|
||||||
msg = ("M004: Unit tests should use assertIsNone(value) instead"
|
msg = ("M004: Unit tests should use assertIsNone(value) instead"
|
||||||
@ -48,12 +56,14 @@ def validate_assertIsNone(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def no_log_warn_check(logical_line):
|
def no_log_warn_check(logical_line):
|
||||||
if re.match(no_log_warn, logical_line):
|
if re.match(no_log_warn, logical_line):
|
||||||
msg = ("M005: LOG.warn is deprecated, please use LOG.warning!")
|
msg = ("M005: LOG.warn is deprecated, please use LOG.warning!")
|
||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def validate_assertIsNotNone(logical_line):
|
def validate_assertIsNotNone(logical_line):
|
||||||
if re.match(assert_Not_Equal, logical_line) or \
|
if re.match(assert_Not_Equal, logical_line) or \
|
||||||
re.match(assert_Is_Not, logical_line):
|
re.match(assert_Is_Not, logical_line):
|
||||||
@ -63,18 +73,9 @@ def validate_assertIsNotNone(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def assert_raisesRegexp(logical_line):
|
def assert_raisesRegexp(logical_line):
|
||||||
res = assert_raises_regexp.search(logical_line)
|
res = assert_raises_regexp.search(logical_line)
|
||||||
if res:
|
if res:
|
||||||
yield (0, "M007: assertRaisesRegex must be used instead "
|
yield (0, "M007: assertRaisesRegex must be used instead "
|
||||||
"of assertRaisesRegexp")
|
"of assertRaisesRegexp")
|
||||||
|
|
||||||
|
|
||||||
def factory(register):
|
|
||||||
register(no_mutable_default_args)
|
|
||||||
register(no_xrange)
|
|
||||||
register(validate_assertTrue)
|
|
||||||
register(validate_assertIsNone)
|
|
||||||
register(no_log_warn_check)
|
|
||||||
register(validate_assertIsNotNone)
|
|
||||||
register(assert_raisesRegexp)
|
|
||||||
|
@ -132,7 +132,7 @@ def main():
|
|||||||
|
|
||||||
# Start
|
# Start
|
||||||
try:
|
try:
|
||||||
LOG.info('''
|
LOG.info(r'''
|
||||||
|
|
||||||
_____
|
_____
|
||||||
/ \ ____ ____ _____ ______ ____ _____
|
/ \ ____ ____ _____ ______ ____ _____
|
||||||
@ -164,5 +164,6 @@ def main():
|
|||||||
LOG.exception('Error! Exiting.')
|
LOG.exception('Error! Exiting.')
|
||||||
clean_exit(signal.SIGKILL)
|
clean_exit(signal.SIGKILL)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
@ -173,9 +173,9 @@ htmlhelp_basename = 'MonitoringApiReleaseNotesDoc'
|
|||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [(
|
latex_documents = [(
|
||||||
master_doc, 'MonitoringPersiterReleaseNotes.tex',
|
master_doc, 'MonitoringPersiterReleaseNotes.tex',
|
||||||
u'Monitoring Persister Release Notes', [author],
|
u'Monitoring Persister Release Notes', [author],
|
||||||
'manual'
|
'manual'
|
||||||
)]
|
)]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
bandit>=1.1.0 # Apache-2.0
|
bandit>=1.1.0 # Apache-2.0
|
||||||
flake8<2.6.0,>=2.5.4 # MIT
|
flake8<2.6.0,>=2.5.4 # MIT
|
||||||
hacking>=1.1.0,<1.2.0 # Apache-2.0
|
hacking>=3.0,<3.1.0 # Apache-2.0
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
oslotest>=3.2.0 # Apache-2.0
|
oslotest>=3.2.0 # Apache-2.0
|
||||||
stestr>=1.0.0 # Apache-2.0
|
stestr>=1.0.0 # Apache-2.0
|
||||||
|
15
tox.ini
15
tox.ini
@ -88,8 +88,19 @@ commands =
|
|||||||
# B303 cassandra metrics repository uses SHA1 for metric_id
|
# B303 cassandra metrics repository uses SHA1 for metric_id
|
||||||
bandit -r monasca_persister -n5 -s B303 -x monasca_persister/tests
|
bandit -r monasca_persister -n5 -s B303 -x monasca_persister/tests
|
||||||
|
|
||||||
[hacking]
|
[flake8:local-plugins]
|
||||||
local-check-factory = monasca_persister.hacking.checks.factory
|
extension =
|
||||||
|
|
||||||
|
|
||||||
|
def factory(register):
|
||||||
|
M001 = checks:no_mutable_default_args
|
||||||
|
M002 = checks:no_xrange
|
||||||
|
M003 = checks:validate_assertTrue
|
||||||
|
M004 = checks:validate_assertIsNone
|
||||||
|
M005 = checks:no_log_warn_check
|
||||||
|
M006 = checks:validate_assertIsNotNone
|
||||||
|
M007 = checks:assert_raisesRegexp
|
||||||
|
paths = ./monasca_persister/hacking
|
||||||
|
|
||||||
[testenv:lower-constraints]
|
[testenv:lower-constraints]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user