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, those are not
needed for co-installing.

Change-Id: I59f0854c089a6ed4f0c4dad7755f946dc95ada3a
This commit is contained in:
Andreas Jaeger 2020-03-31 17:04:21 +02:00
parent 1fd67089f7
commit c096099416
13 changed files with 36 additions and 33 deletions

View File

@ -13,7 +13,7 @@
from keystoneauth1.access.access import * # noqa
__all__ = ('AccessInfo',
'AccessInfoV2',
'AccessInfoV3',
'create')
__all__ = ('AccessInfo', # noqa: F405
'AccessInfoV2', # noqa: F405
'AccessInfoV3', # noqa: F405
'create') # noqa: F405

View File

@ -77,10 +77,10 @@ def _response_xml(response, name):
def _str_from_xml(xml, path):
l = xml.xpath(path, namespaces=_XML_NAMESPACES)
if len(l) != 1:
li = xml.xpath(path, namespaces=_XML_NAMESPACES)
if len(li) != 1:
raise IndexError('%s should provide a single element list' % path)
return l[0]
return li[0]
class _SamlAuth(requests.auth.AuthBase):

View File

@ -19,6 +19,8 @@ main client (keystoneauth or other). Because of this there may be dependencies
from this module on libraries that are only available in testing.
"""
# flake8: noqa: F405
from keystoneauth1.fixture.discovery import * # noqa
from keystoneauth1.fixture import exception
from keystoneauth1.fixture.plugin import * # noqa

View File

@ -21,7 +21,10 @@ errors so that core devs don't have to.
import re
from hacking import core
@core.flake8ext
def check_oslo_namespace_imports(logical_line, blank_before, filename):
oslo_namespace_imports = re.compile(
r"(((from)|(import))\s+oslo\.)|(from\s+oslo\s+import\s+)")
@ -31,7 +34,3 @@ def check_oslo_namespace_imports(logical_line, blank_before, filename):
logical_line.replace('oslo.', 'oslo_'),
logical_line)
yield(0, msg)
def factory(register):
register(check_oslo_namespace_imports)

View File

@ -213,7 +213,7 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
# implementation to respond with a dict without the subclass modifying
# it to add their own data in case the subclass doesn't support caching
if not _implemented:
raise NotImplemented()
raise NotImplementedError()
return {'auth_url': self.auth_url,
'project_id': self._project_id,

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
# flake8: noqa: F405
from keystoneauth1.identity.v3.application_credential import * # noqa
from keystoneauth1.identity.v3.base import * # noqa
from keystoneauth1.identity.v3.federation import * # noqa

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
# flake8: noqa: F405
from keystoneauth1.loading import adapter
from keystoneauth1.loading.base import * # noqa
from keystoneauth1.loading import cli

View File

@ -113,9 +113,9 @@ class ConfTests(utils.TestCase):
self.assertEqual(auth_type, e.name)
def test_loading_with_no_data(self):
l = loading.load_auth_from_conf_options(self.conf_fixture.conf,
self.GROUP)
self.assertIsNone(l)
lo = loading.load_auth_from_conf_options(self.conf_fixture.conf,
self.GROUP)
self.assertIsNone(lo)
@mock.patch('stevedore.DriverManager')
def test_other_params(self, m):

View File

@ -55,14 +55,14 @@ class LoadingTests(utils.TestCase):
Plugin, Loader = utils.create_plugin(opts=opts)
l = Loader()
lo = Loader()
v = uuid.uuid4().hex
p1 = l.load_from_options(b=v)
p1 = lo.load_from_options(b=v)
self.assertEqual(v, p1['b'])
e = self.assertRaises(exceptions.MissingRequiredOptions,
l.load_from_options,
lo.load_from_options,
a=v)
self.assertEqual(1, len(e.options))

View File

@ -13,7 +13,7 @@
import textwrap
import mock
import pep8
import pycodestyle
import testtools
from keystoneauth1.hacking import checks
@ -22,16 +22,16 @@ from keystoneauth1.tests.unit import keystoneauth_fixtures
class TestCheckOsloNamespaceImports(testtools.TestCase):
# 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.
@mock.patch('pep8._checks',
@mock.patch('pycodestyle._checks',
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
def run_check(self, code):
pep8.register_check(checks.check_oslo_namespace_imports)
pycodestyle.register_check(checks.check_oslo_namespace_imports)
lines = textwrap.dedent(code).strip().splitlines(True)
checker = pep8.Checker(lines=lines)
checker = pycodestyle.Checker(lines=lines)
checker.check_all()
checker.report._deferred_print.sort()
return checker.report._deferred_print

View File

@ -13,13 +13,9 @@ docutils==0.14
dulwich==0.19.0
extras==1.0.0
fixtures==3.0.0
flake8-docstrings==0.2.1.post1
flake8-import-order==0.17.1
flake8==2.5.5
future==0.16.0
gitdb2==2.0.3
GitPython==2.1.8
hacking==0.12.0
idna==2.6
imagesize==1.0.0
iso8601==0.1.11
@ -46,10 +42,8 @@ packaging==17.1
Parsley==1.3
pbr==2.0.0
pep257==0.7.0
pep8==1.5.7
prettytable==0.7.2
pycodestyle==2.3.1
pyflakes==0.8.1
Pygments==2.2.0
pyparsing==2.2.0
pyperclip==1.6.0

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=3.0,<3.1.0 # Apache-2.0
flake8-docstrings==0.2.1.post1 # MIT
flake8-import-order>=0.17.1 #LGPLv3

10
tox.ini
View File

@ -54,7 +54,9 @@ commands = oslo_debug_helper -t keystoneauth1/tests {posargs}
# D103: Missing docstring in public function
# D104: Missing docstring in public package
# D203: 1 blank line required before class docstring (deprecated in pep257)
ignore = D100,D101,D102,D103,D104,D203
# W503 line break before binary operator
# W504 line break after binary operator
ignore = D100,D101,D102,D103,D104,D203,W503,W504
# H106: Dont put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
enable-extensions=H106,H203
@ -89,8 +91,10 @@ deps =
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[hacking]
local-check-factory = keystoneauth1.hacking.checks.factory
[flake8:local-plugins]
extension =
K333 = checks:check_oslo_namespace_imports
paths = ./keystoneauth1/hacking
[testenv:lower-constraints]
deps =