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. Update local hacking checks for new flake8. Remove hacking and friends from lower-constraints, they are not needed in installations. Change-Id: I6e6638c07b5d24c90e9deae277e98149f383eb3d
This commit is contained in:
parent
3cdcfac30b
commit
f33c213051
@ -33,13 +33,11 @@ eventlet==0.18.2
|
|||||||
extras==1.0.0
|
extras==1.0.0
|
||||||
fasteners==0.14.1
|
fasteners==0.14.1
|
||||||
fixtures==3.0.0
|
fixtures==3.0.0
|
||||||
flake8==2.5.5
|
|
||||||
future==0.16.0
|
future==0.16.0
|
||||||
futurist==1.6.0
|
futurist==1.6.0
|
||||||
gitdb2==2.0.3
|
gitdb2==2.0.3
|
||||||
GitPython==2.1.8
|
GitPython==2.1.8
|
||||||
greenlet==0.4.13
|
greenlet==0.4.13
|
||||||
hacking==0.12.0
|
|
||||||
httplib2==0.9.1
|
httplib2==0.9.1
|
||||||
idna==2.6
|
idna==2.6
|
||||||
imagesize==1.0.0
|
imagesize==1.0.0
|
||||||
@ -96,7 +94,6 @@ passlib==1.7.0
|
|||||||
Paste==2.0.2
|
Paste==2.0.2
|
||||||
PasteDeploy==1.5.0
|
PasteDeploy==1.5.0
|
||||||
pbr==2.0.0
|
pbr==2.0.0
|
||||||
pep8==1.7.1
|
|
||||||
pexpect==3.1
|
pexpect==3.1
|
||||||
pika-pool==0.1.3
|
pika-pool==0.1.3
|
||||||
pika==0.10.0
|
pika==0.10.0
|
||||||
@ -106,7 +103,6 @@ psycopg2==2.6.2
|
|||||||
ptyprocess==0.5.2
|
ptyprocess==0.5.2
|
||||||
pycadf==2.7.0
|
pycadf==2.7.0
|
||||||
pycparser==2.18
|
pycparser==2.18
|
||||||
pyflakes==1.0.0
|
|
||||||
Pygments==2.2.0
|
Pygments==2.2.0
|
||||||
pyinotify==0.9.6
|
pyinotify==0.9.6
|
||||||
pylint==1.9.2 # GPLv2
|
pylint==1.9.2 # GPLv2
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# of appearance. Changing the order has an impact on the overall integration
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
# Hacking already pins down pep8, pyflakes and flake8
|
# Hacking already pins down pep8, pyflakes and flake8
|
||||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
hacking>=3.0,<3.1.0 # Apache-2.0
|
||||||
bandit>=1.1.0 # Apache-2.0
|
bandit>=1.1.0 # Apache-2.0
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
nose>=1.3.7 # LGPL
|
nose>=1.3.7 # LGPL
|
||||||
|
9
tox.ini
9
tox.ini
@ -65,7 +65,14 @@ filename=*.py,trove-*,app.wsgi
|
|||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
import_exceptions = trove.common.i18n
|
import_exceptions = trove.common.i18n
|
||||||
local-check-factory = trove.hacking.checks.factory
|
|
||||||
|
[flake8:local-plugins]
|
||||||
|
extension =
|
||||||
|
T103= checks:check_raised_localized_exceptions
|
||||||
|
T104 = checks:check_no_basestring
|
||||||
|
T105 = checks:no_translate_logs
|
||||||
|
N335 = checks:assert_raises_regexp
|
||||||
|
paths = ./trove/hacking
|
||||||
|
|
||||||
[testenv:api-ref]
|
[testenv:api-ref]
|
||||||
# This environment is called from CI scripts to test and publish
|
# This environment is called from CI scripts to test and publish
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pep8
|
import pycodestyle
|
||||||
|
|
||||||
|
from hacking import core
|
||||||
|
|
||||||
_all_log_levels = (
|
_all_log_levels = (
|
||||||
'critical',
|
'critical',
|
||||||
@ -34,6 +36,7 @@ def _translation_is_not_expected(filename):
|
|||||||
return any(pat in filename for pat in ["/tests/"])
|
return any(pat in filename for pat in ["/tests/"])
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def check_raised_localized_exceptions(logical_line, filename):
|
def check_raised_localized_exceptions(logical_line, filename):
|
||||||
"""T103 - Untranslated exception message.
|
"""T103 - Untranslated exception message.
|
||||||
:param logical_line: The logical line to check.
|
:param logical_line: The logical line to check.
|
||||||
@ -55,6 +58,7 @@ def check_raised_localized_exceptions(logical_line, filename):
|
|||||||
yield (logical_line.index(exception_msg), msg)
|
yield (logical_line.index(exception_msg), msg)
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def check_no_basestring(logical_line):
|
def check_no_basestring(logical_line):
|
||||||
"""T104 - Don't use basestring, use six.string_types instead
|
"""T104 - Don't use basestring, use six.string_types instead
|
||||||
basestring is not supported by py3, using six.string_types to ensure
|
basestring is not supported by py3, using six.string_types to ensure
|
||||||
@ -66,7 +70,8 @@ def check_no_basestring(logical_line):
|
|||||||
yield(0, msg)
|
yield(0, msg)
|
||||||
|
|
||||||
|
|
||||||
def no_translate_logs(logical_line, physical_line, filename):
|
@core.flake8ext
|
||||||
|
def no_translate_logs(physical_line, logical_line, filename):
|
||||||
"""T105 - Log messages shouldn't be translated from the
|
"""T105 - Log messages shouldn't be translated from the
|
||||||
Pike release.
|
Pike release.
|
||||||
:param logical_line: The logical line to check.
|
:param logical_line: The logical line to check.
|
||||||
@ -79,7 +84,7 @@ def no_translate_logs(logical_line, physical_line, filename):
|
|||||||
if _translation_is_not_expected(filename):
|
if _translation_is_not_expected(filename):
|
||||||
return
|
return
|
||||||
|
|
||||||
if pep8.noqa(physical_line):
|
if pycodestyle.noqa(physical_line):
|
||||||
return
|
return
|
||||||
|
|
||||||
msg = "T105: Log message shouldn't be translated."
|
msg = "T105: Log message shouldn't be translated."
|
||||||
@ -90,6 +95,7 @@ def no_translate_logs(logical_line, physical_line, filename):
|
|||||||
asse_raises_regexp = re.compile(r"assertRaisesRegexp\(")
|
asse_raises_regexp = re.compile(r"assertRaisesRegexp\(")
|
||||||
|
|
||||||
|
|
||||||
|
@core.flake8ext
|
||||||
def assert_raises_regexp(logical_line):
|
def assert_raises_regexp(logical_line):
|
||||||
"""Check for usage of deprecated assertRaisesRegexp
|
"""Check for usage of deprecated assertRaisesRegexp
|
||||||
|
|
||||||
@ -99,10 +105,3 @@ def assert_raises_regexp(logical_line):
|
|||||||
if res:
|
if res:
|
||||||
yield (0, "N335: assertRaisesRegex must be used instead "
|
yield (0, "N335: assertRaisesRegex must be used instead "
|
||||||
"of assertRaisesRegexp")
|
"of assertRaisesRegexp")
|
||||||
|
|
||||||
|
|
||||||
def factory(register):
|
|
||||||
register(check_raised_localized_exceptions)
|
|
||||||
register(check_no_basestring)
|
|
||||||
register(no_translate_logs)
|
|
||||||
register(assert_raises_regexp)
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import pep8
|
import pycodestyle
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from trove.hacking import checks as tc
|
from trove.hacking import checks as tc
|
||||||
@ -28,11 +28,6 @@ class HackingTestCase(trove_testtools.TestCase):
|
|||||||
def assertLineFails(self, func, *args):
|
def assertLineFails(self, func, *args):
|
||||||
self.assertIsInstance(next(func(*args)), tuple)
|
self.assertIsInstance(next(func(*args)), tuple)
|
||||||
|
|
||||||
def test_factory(self):
|
|
||||||
def check_callable(fn):
|
|
||||||
self.assertTrue(hasattr(fn, '__call__'))
|
|
||||||
self.assertIsNone(tc.factory(check_callable))
|
|
||||||
|
|
||||||
def test_log_translations(self):
|
def test_log_translations(self):
|
||||||
all_log_levels = (
|
all_log_levels = (
|
||||||
'critical',
|
'critical',
|
||||||
@ -89,20 +84,20 @@ class HackingTestCase(trove_testtools.TestCase):
|
|||||||
0,
|
0,
|
||||||
len(list(tc.check_no_basestring("this basestring is good)"))))
|
len(list(tc.check_no_basestring("this basestring is good)"))))
|
||||||
|
|
||||||
# We are patching pep8 so that only the check under test is actually
|
# We are patching pycodestyle so that only the check under test is actually
|
||||||
# installed.
|
# installed.
|
||||||
@mock.patch('pep8._checks',
|
@mock.patch('pycodestyle._checks',
|
||||||
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
|
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
|
||||||
def _run_check(self, code, checker, filename=None):
|
def _run_check(self, code, checker, filename=None):
|
||||||
pep8.register_check(checker)
|
pycodestyle.register_check(checker)
|
||||||
|
|
||||||
lines = textwrap.dedent(code).strip().splitlines(True)
|
lines = textwrap.dedent(code).strip().splitlines(True)
|
||||||
|
|
||||||
checker = pep8.Checker(filename=filename, lines=lines)
|
checker = pycodestyle.Checker(filename=filename, lines=lines)
|
||||||
# NOTE(sdague): the standard reporter has printing to stdout
|
# NOTE(sdague): the standard reporter has printing to stdout
|
||||||
# as a normal part of check_all, which bleeds through to the
|
# as a normal part of check_all, which bleeds through to the
|
||||||
# test output stream in an unhelpful way. This blocks that printing.
|
# test output stream in an unhelpful way. This blocks that printing.
|
||||||
with mock.patch('pep8.StandardReport.get_file_results'):
|
with mock.patch('pycodestyle.StandardReport.get_file_results'):
|
||||||
checker.check_all()
|
checker.check_all()
|
||||||
checker.report._deferred_print.sort()
|
checker.report._deferred_print.sort()
|
||||||
return checker.report._deferred_print
|
return checker.report._deferred_print
|
||||||
|
Loading…
x
Reference in New Issue
Block a user