Replace use of functools.wraps() with six.wraps()
In Python 2.7, functools.wraps() does not provide the '__wrapped__' attribute. This attribute is used by oslo_utils.reflection.get_signature() when getting the signature of a function. If a function is decorated without the '__wrapped__' attribute then the signature will be of the decorator rather than the underlying function. From the six documentation for six.wraps(): This is exactly the functools.wraps() decorator, but it sets the __wrapped__ attribute on what it decorates as functools.wraps() does on Python versions after 3.2. Change-Id: I11bf2fa945d36bfbc89ec8239e7c9259e3e12496
This commit is contained in:
parent
81de9dc06e
commit
15d5958e17
@ -11,12 +11,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import functools
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
import six
|
||||||
import werkzeug
|
import werkzeug
|
||||||
|
|
||||||
from ironic_inspector import api_tools
|
from ironic_inspector import api_tools
|
||||||
@ -70,7 +70,7 @@ def error_response(exc, code=500):
|
|||||||
|
|
||||||
|
|
||||||
def convert_exceptions(func):
|
def convert_exceptions(func):
|
||||||
@functools.wraps(func)
|
@six.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
@ -168,7 +168,7 @@ def api(path, is_public_api=False, rule=None, verb_to_rule_map=None,
|
|||||||
def outer(func):
|
def outer(func):
|
||||||
@app.route(path, **flask_kwargs)
|
@app.route(path, **flask_kwargs)
|
||||||
@convert_exceptions
|
@convert_exceptions
|
||||||
@functools.wraps(func)
|
@six.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
flask.request.context = context.RequestContext.from_environ(
|
flask.request.context = context.RequestContext.from_environ(
|
||||||
flask.request.environ,
|
flask.request.environ,
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
"""Base code for PXE boot filtering."""
|
"""Base code for PXE boot filtering."""
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import functools
|
|
||||||
|
|
||||||
from automaton import exceptions as automaton_errors
|
from automaton import exceptions as automaton_errors
|
||||||
from automaton import machines
|
from automaton import machines
|
||||||
@ -23,6 +22,7 @@ from futurist import periodics
|
|||||||
from oslo_concurrency import lockutils
|
from oslo_concurrency import lockutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
import six
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
from ironic_inspector.common.i18n import _
|
from ironic_inspector.common.i18n import _
|
||||||
@ -74,7 +74,7 @@ State_space = [
|
|||||||
def locked_driver_event(event):
|
def locked_driver_event(event):
|
||||||
"""Call driver method having processed the fsm event."""
|
"""Call driver method having processed the fsm event."""
|
||||||
def outer(method):
|
def outer(method):
|
||||||
@functools.wraps(method)
|
@six.wraps(method)
|
||||||
def inner(self, *args, **kwargs):
|
def inner(self, *args, **kwargs):
|
||||||
with self.lock, self.fsm_reset_on_error() as fsm:
|
with self.lock, self.fsm_reset_on_error() as fsm:
|
||||||
fsm.process_event(event)
|
fsm.process_event(event)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import functools
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -26,6 +25,7 @@ from oslo_config import cfg
|
|||||||
from oslo_serialization import base64
|
from oslo_serialization import base64
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
import six
|
||||||
|
|
||||||
from ironic_inspector.common import ironic as ir_utils
|
from ironic_inspector.common import ironic as ir_utils
|
||||||
from ironic_inspector import db
|
from ironic_inspector import db
|
||||||
@ -524,7 +524,7 @@ class TestProcessNode(BaseTest):
|
|||||||
@mock.patch.object(node_cache, 'get_node', autospec=True)
|
@mock.patch.object(node_cache, 'get_node', autospec=True)
|
||||||
class TestReapply(BaseTest):
|
class TestReapply(BaseTest):
|
||||||
def prepare_mocks(func):
|
def prepare_mocks(func):
|
||||||
@functools.wraps(func)
|
@six.wraps(func)
|
||||||
def wrapper(self, pop_mock, *args, **kw):
|
def wrapper(self, pop_mock, *args, **kw):
|
||||||
pop_mock.return_value = node_cache.NodeInfo(
|
pop_mock.return_value = node_cache.NodeInfo(
|
||||||
uuid=self.node.uuid,
|
uuid=self.node.uuid,
|
||||||
@ -600,7 +600,7 @@ class TestReapplyNode(BaseTest):
|
|||||||
self.node_info.release_lock.assert_called_once_with(self.node_info)
|
self.node_info.release_lock.assert_called_once_with(self.node_info)
|
||||||
|
|
||||||
def prepare_mocks(fn):
|
def prepare_mocks(fn):
|
||||||
@functools.wraps(fn)
|
@six.wraps(fn)
|
||||||
def wrapper(self, release_mock, finished_mock, swift_mock,
|
def wrapper(self, release_mock, finished_mock, swift_mock,
|
||||||
*args, **kw):
|
*args, **kw):
|
||||||
finished_mock.side_effect = lambda *a, **kw: \
|
finished_mock.side_effect = lambda *a, **kw: \
|
||||||
|
Loading…
Reference in New Issue
Block a user