Address nits from six removal patch
Change-Id: Ia487c2961849a1d42eb72b2a69c360ea638f9d1b Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
cfe9881e6b
commit
6ccdbd3731
@ -20,10 +20,10 @@ def flatten_dict_to_keypairs(d, separator=':'):
|
|||||||
:param d: dictionaries which may be nested
|
:param d: dictionaries which may be nested
|
||||||
:param separator: symbol between names
|
:param separator: symbol between names
|
||||||
"""
|
"""
|
||||||
for name, value in sorted(iter(d.items())):
|
for name, value in sorted(d.items()):
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
for subname, subvalue in flatten_dict_to_keypairs(value,
|
for subname, subvalue in flatten_dict_to_keypairs(value,
|
||||||
separator):
|
separator):
|
||||||
yield ('%s%s%s' % (name, separator, subname), subvalue)
|
yield '%s%s%s' % (name, separator, subname), subvalue
|
||||||
else:
|
else:
|
||||||
yield name, value
|
yield name, value
|
||||||
|
@ -283,8 +283,7 @@ def is_valid_mac(address):
|
|||||||
.. versionadded:: 3.17
|
.. versionadded:: 3.17
|
||||||
"""
|
"""
|
||||||
m = "[0-9a-f]{2}(:[0-9a-f]{2}){5}$"
|
m = "[0-9a-f]{2}(:[0-9a-f]{2}){5}$"
|
||||||
return (isinstance(address, str) and
|
return isinstance(address, str) and re.match(m, address.lower())
|
||||||
re.match(m, address.lower()))
|
|
||||||
|
|
||||||
|
|
||||||
def _is_int_in_range(value, start, end):
|
def _is_int_in_range(value, start, end):
|
||||||
|
@ -223,8 +223,8 @@ def get_callable_args(function, required_only=False):
|
|||||||
are not included into output.
|
are not included into output.
|
||||||
"""
|
"""
|
||||||
sig = get_signature(function)
|
sig = get_signature(function)
|
||||||
function_args = list(iter(sig.parameters.keys()))
|
function_args = list(sig.parameters.keys())
|
||||||
for param_name, p in iter(sig.parameters.items()):
|
for param_name, p in sig.parameters.items():
|
||||||
if (p.kind in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD) or
|
if (p.kind in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD) or
|
||||||
(required_only and p.default is not Parameter.empty)):
|
(required_only and p.default is not Parameter.empty)):
|
||||||
function_args.remove(param_name)
|
function_args.remove(param_name)
|
||||||
@ -234,5 +234,6 @@ def get_callable_args(function, required_only=False):
|
|||||||
def accepts_kwargs(function):
|
def accepts_kwargs(function):
|
||||||
"""Returns ``True`` if function accepts kwargs otherwise ``False``."""
|
"""Returns ``True`` if function accepts kwargs otherwise ``False``."""
|
||||||
sig = get_signature(function)
|
sig = get_signature(function)
|
||||||
return any(p.kind == Parameter.VAR_KEYWORD
|
return any(
|
||||||
for p in iter(sig.parameters.values()))
|
p.kind == Parameter.VAR_KEYWORD for p in sig.parameters.values()
|
||||||
|
)
|
||||||
|
@ -22,8 +22,9 @@ from oslotest import base as test_base
|
|||||||
from oslo_utils import reflection
|
from oslo_utils import reflection
|
||||||
|
|
||||||
|
|
||||||
RUNTIME_ERROR_CLASSES = ['RuntimeError', 'Exception',
|
RUNTIME_ERROR_CLASSES = [
|
||||||
'BaseException', 'object']
|
'RuntimeError', 'Exception', 'BaseException', 'object',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def dummy_decorator(f):
|
def dummy_decorator(f):
|
||||||
@ -187,8 +188,7 @@ class GetCallableNameTest(test_base.BaseTestCase):
|
|||||||
|
|
||||||
def test_static_method(self):
|
def test_static_method(self):
|
||||||
name = reflection.get_callable_name(Class.static_method)
|
name = reflection.get_callable_name(Class.static_method)
|
||||||
self.assertEqual('.'.join((__name__, 'Class', 'static_method')),
|
self.assertEqual('.'.join((__name__, 'Class', 'static_method')), name)
|
||||||
name)
|
|
||||||
|
|
||||||
def test_class_method(self):
|
def test_class_method(self):
|
||||||
name = reflection.get_callable_name(Class.class_method)
|
name = reflection.get_callable_name(Class.class_method)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user