Merge "Get rid of thin redundant wrapper"

This commit is contained in:
Zuul
2025-08-12 13:37:38 +00:00
committed by Gerrit Code Review
4 changed files with 7 additions and 25 deletions

View File

@@ -21,6 +21,7 @@
import ast
import datetime
import functools
import inspect
from oslo_utils import strutils
from oslo_utils import timeutils
@@ -29,7 +30,6 @@ import wsme
from wsme import types as wtypes
from aodh.i18n import _
from aodh.utils import get_func_valid_keys
operation_kind = ('lt', 'le', 'eq', 'ne', 'ge', 'gt')
@@ -87,7 +87,7 @@ class Base(wtypes.DynamicBase):
return cls(links=links, **(m.as_dict()))
def as_dict(self, db_model):
valid_keys = get_func_valid_keys(db_model.__init__)
valid_keys = inspect.getfullargspec(db_model.__init__)[0]
if 'self' in valid_keys:
valid_keys.remove('self')
return self.as_dict_from_keys(valid_keys)

View File

@@ -20,6 +20,7 @@
import copy
import datetime
import inspect
from oslo_utils import timeutils
import pecan
@@ -28,7 +29,6 @@ import wsme
from aodh.api.controllers.v2 import base
from aodh.api import rbac
from aodh.utils import get_func_valid_keys
def get_auth_project(on_behalf_of=None):
@@ -63,7 +63,7 @@ def sanitize_query(query, db_func, on_behalf_of=None):
_verify_query_segregation(q, auth_project)
proj_q = [i for i in q if i.field == 'project_id']
valid_keys = get_func_valid_keys(db_func)
valid_keys = inspect.getfullargspec(db_func)[0]
if not proj_q and 'on_behalf_of' not in valid_keys:
# The user is restricted, but they didn't specify a project
# so add it for them.
@@ -112,7 +112,7 @@ def validate_query(query, db_func, internal_keys=None,
internal_keys = internal_keys or []
_verify_query_segregation(query)
valid_keys = get_func_valid_keys(db_func)
valid_keys = inspect.getfullargspec(db_func)[0]
if 'alarm_type' in valid_keys:
valid_keys.remove('alarm_type')
valid_keys.append('type')

View File

@@ -15,9 +15,9 @@
"""Base classes for storage engines
"""
import copy
import inspect
import aodh
from aodh.utils import get_func_valid_keys
def update_nested(original_dict, updates):
@@ -62,7 +62,7 @@ class Model:
@classmethod
def get_field_names(cls):
fields = get_func_valid_keys(cls.__init__)
fields = inspect.getfullargspec(cls.__init__)[0]
return set(fields) - {"self"}

View File

@@ -1,18 +0,0 @@
# Copyright 2019 - Nokia Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import inspect
def get_func_valid_keys(func):
return inspect.getfullargspec(func)[0]