Merge "pyupgrade changes for Python3.8+ (2)"

This commit is contained in:
Zuul 2024-04-12 18:03:28 +00:00 committed by Gerrit Code Review
commit f91ff6c5a6
21 changed files with 40 additions and 43 deletions

View File

@ -80,8 +80,7 @@ def _wrap_app(app):
audit_map_file=CONF.audit.audit_map_file,
ignore_req_list=CONF.audit.ignore_req_list
)
except (EnvironmentError, OSError,
audit_middleware.PycadfAuditApiConfigError) as e:
except (OSError, audit_middleware.PycadfAuditApiConfigError) as e:
raise exceptions.InputFileError(
file_name=CONF.audit.audit_map_file,
reason=e

View File

@ -32,7 +32,7 @@ CONF = cfg.CONF
LOG = logging.getLogger(__name__)
class PaginationHelper(object):
class PaginationHelper:
"""Class helping to interact with pagination functionality
Pass this class to `db.repositories` to apply it on query
@ -149,7 +149,7 @@ class PaginationHelper(object):
path_url = request.path_url
links = []
if model_list:
prev_attr = ["limit={}".format(self.limit)]
prev_attr = [f"limit={self.limit}"]
if self.params.get('sort'):
prev_attr.append("sort={}".format(self.params.get('sort')))
if self.params.get('sort_key'):
@ -361,7 +361,7 @@ class PaginationHelper(object):
attr = sa_sql.expression.case(
(model_attr.isnot(None), model_attr),
else_=default)
crit_attrs.append((attr == marker_values[j]))
crit_attrs.append(attr == marker_values[j])
model_attr = getattr(model, self.sort_keys[i][0])
default = PaginationHelper._get_default_column_value(
@ -372,14 +372,14 @@ class PaginationHelper(object):
this_sort_dir = self.sort_keys[i][1]
if this_sort_dir == constants.DESC:
if self.page_reverse == "True":
crit_attrs.append((attr > marker_values[i]))
crit_attrs.append(attr > marker_values[i])
else:
crit_attrs.append((attr < marker_values[i]))
crit_attrs.append(attr < marker_values[i])
elif this_sort_dir == constants.ASC:
if self.page_reverse == "True":
crit_attrs.append((attr < marker_values[i]))
crit_attrs.append(attr < marker_values[i])
else:
crit_attrs.append((attr > marker_values[i]))
crit_attrs.append(attr > marker_values[i])
else:
raise exceptions.InvalidSortDirection(
key=this_sort_dir)

View File

@ -127,7 +127,7 @@ class BaseMeta(wtypes.BaseMeta):
get_tenant_id, set_tenant_id)
# This will let us know if tenant_id was explicitly set to Unset
dct['_unset_tenant'] = False
return super(BaseMeta, mcs).__new__(mcs, name, bases, dct)
return super().__new__(mcs, name, bases, dct)
class BaseType(wtypes.Base, metaclass=BaseMeta):

View File

@ -473,9 +473,9 @@ class AmphoraProviderDriver(driver_base.ProviderDriver):
except js_exceptions.ValidationError as e:
error_object = ''
if e.relative_path:
error_object = '{} '.format(e.relative_path[0])
error_object = f'{e.relative_path[0]} '
raise exceptions.UnsupportedOptionError(
user_fault_string='{0}{1}'.format(error_object, e.message),
user_fault_string=f'{error_object}{e.message}',
operator_fault_string=str(e))
except Exception as e:
raise exceptions.DriverError(
@ -559,9 +559,9 @@ class AmphoraProviderDriver(driver_base.ProviderDriver):
except js_exceptions.ValidationError as e:
error_object = ''
if e.relative_path:
error_object = '{} '.format(e.relative_path[0])
error_object = f'{e.relative_path[0]} '
raise exceptions.UnsupportedOptionError(
user_fault_string='{0}{1}'.format(error_object, e.message),
user_fault_string=f'{error_object}{e.message}',
operator_fault_string=str(e))
except Exception as e:
raise exceptions.DriverError(

View File

@ -62,7 +62,7 @@ class StatusRequestHandler(socketserver.BaseRequestHandler):
# Send the response
json_data = jsonutils.dump_as_bytes(response)
len_str = '{}\n'.format(len(json_data)).encode('utf-8')
len_str = f'{len(json_data)}\n'.encode()
try:
self.request.send(len_str)
self.request.sendall(json_data)
@ -86,7 +86,7 @@ class StatsRequestHandler(socketserver.BaseRequestHandler):
# Send the response
json_data = jsonutils.dump_as_bytes(response)
len_str = '{}\n'.format(len(json_data)).encode('utf-8')
len_str = f'{len(json_data)}\n'.encode()
try:
self.request.send(len_str)
self.request.sendall(json_data)
@ -109,7 +109,7 @@ class GetRequestHandler(socketserver.BaseRequestHandler):
# Send the response
json_data = jsonutils.dump_as_bytes(response)
len_str = '{}\n'.format(len(json_data)).encode('utf-8')
len_str = f'{len(json_data)}\n'.encode()
try:
self.request.send(len_str)
self.request.sendall(json_data)

View File

@ -29,7 +29,7 @@ from octavia.statistics import stats_base
LOG = logging.getLogger(__name__)
class DriverUpdater(object):
class DriverUpdater:
def __init__(self, **kwargs):
self.repos = repo.Repositories()

View File

@ -23,7 +23,7 @@ from octavia.api.drivers import utils as driver_utils
LOG = logging.getLogger(__name__)
class NoopManager(object):
class NoopManager:
def __init__(self):
super().__init__()
self.driverconfig = {}

View File

@ -27,7 +27,7 @@ CONF = cfg.CONF
LOG = logging.getLogger(__name__)
class RootController(object):
class RootController:
"""The controller with which the pecan wsgi app should be created."""
def __init__(self):
@ -65,7 +65,7 @@ class RootController(object):
host_url = pecan_request.path_url
if not host_url.endswith('/'):
host_url = '{}/'.format(host_url)
host_url = f'{host_url}/'
versions = []
self._add_a_version(versions, 'v2.0', 'v2', 'SUPPORTED',

View File

@ -47,7 +47,7 @@ class AmphoraResponse(BaseAmphoraType):
@classmethod
def from_data_model(cls, data_model, children=False):
amphorae = super(AmphoraResponse, cls).from_data_model(
amphorae = super().from_data_model(
data_model, children=children)
return amphorae

View File

@ -31,8 +31,7 @@ class AvailabilityZoneProfileResponse(BaseAvailabilityZoneProfileType):
@classmethod
def from_data_model(cls, data_model, children=False):
availability_zone_profile = super(
AvailabilityZoneProfileResponse, cls).from_data_model(
availability_zone_profile = super().from_data_model(
data_model, children=children)
return availability_zone_profile

View File

@ -31,8 +31,7 @@ class AvailabilityZoneResponse(BaseAvailabilityZoneType):
@classmethod
def from_data_model(cls, data_model, children=False):
availability_zone = super(
AvailabilityZoneResponse, cls).from_data_model(
availability_zone = super().from_data_model(
data_model, children=children)
return availability_zone

View File

@ -31,7 +31,7 @@ class FlavorProfileResponse(BaseFlavorProfileType):
@classmethod
def from_data_model(cls, data_model, children=False):
flavorprofile = super(FlavorProfileResponse, cls).from_data_model(
flavorprofile = super().from_data_model(
data_model, children=children)
return flavorprofile

View File

@ -32,7 +32,7 @@ class FlavorResponse(BaseFlavorType):
@classmethod
def from_data_model(cls, data_model, children=False):
flavor = super(FlavorResponse, cls).from_data_model(
flavor = super().from_data_model(
data_model, children=children)
return flavor

View File

@ -50,7 +50,7 @@ class HealthMonitorResponse(BaseHealthMonitorType):
@classmethod
def from_data_model(cls, data_model, children=False):
healthmonitor = super(HealthMonitorResponse, cls).from_data_model(
healthmonitor = super().from_data_model(
data_model, children=children)
if cls._full_response():

View File

@ -48,7 +48,7 @@ class L7PolicyResponse(BaseL7PolicyType):
@classmethod
def from_data_model(cls, data_model, children=False):
policy = super(L7PolicyResponse, cls).from_data_model(
policy = super().from_data_model(
data_model, children=children)
if cls._full_response():

View File

@ -41,7 +41,7 @@ class L7RuleResponse(BaseL7Type):
@classmethod
def from_data_model(cls, data_model, children=False):
rule = super(L7RuleResponse, cls).from_data_model(
rule = super().from_data_model(
data_model, children=children)
return rule

View File

@ -69,7 +69,7 @@ class ListenerResponse(BaseListenerType):
@classmethod
def from_data_model(cls, data_model, children=False):
listener = super(ListenerResponse, cls).from_data_model(
listener = super().from_data_model(
data_model, children=children)
listener.sni_container_refs = [
@ -274,7 +274,7 @@ class ListenerStatusResponse(BaseListenerType):
@classmethod
def from_data_model(cls, data_model, children=False):
listener = super(ListenerStatusResponse, cls).from_data_model(
listener = super().from_data_model(
data_model, children=children)
pool_model = pool.PoolStatusResponse
@ -297,7 +297,7 @@ class ListenerStatisticsResponse(BaseListenerType):
@classmethod
def from_data_model(cls, data_model, children=False):
result = super(ListenerStatisticsResponse, cls).from_data_model(
result = super().from_data_model(
data_model, children=children)
return result

View File

@ -69,7 +69,7 @@ class LoadBalancerResponse(BaseLoadBalancerType):
@classmethod
def from_data_model(cls, data_model, children=False):
result = super(LoadBalancerResponse, cls).from_data_model(
result = super().from_data_model(
data_model, children=children)
if data_model.vip:
result.vip_subnet_id = data_model.vip.subnet_id
@ -169,7 +169,7 @@ class LoadBalancerStatusResponse(BaseLoadBalancerType):
@classmethod
def from_data_model(cls, data_model, children=False):
result = super(LoadBalancerStatusResponse, cls).from_data_model(
result = super().from_data_model(
data_model, children=children)
listener_model = listener.ListenerStatusResponse
result.listeners = [
@ -198,7 +198,7 @@ class LoadBalancerStatisticsResponse(BaseLoadBalancerType):
@classmethod
def from_data_model(cls, data_model, children=False):
result = super(LoadBalancerStatisticsResponse, cls).from_data_model(
result = super().from_data_model(
data_model, children=children)
return result

View File

@ -45,7 +45,7 @@ class MemberResponse(BaseMemberType):
@classmethod
def from_data_model(cls, data_model, children=False):
member = super(MemberResponse, cls).from_data_model(
member = super().from_data_model(
data_model, children=children)
return member
@ -142,7 +142,7 @@ class MemberStatusResponse(BaseMemberType):
@classmethod
def from_data_model(cls, data_model, children=False):
member = super(MemberStatusResponse, cls).from_data_model(
member = super().from_data_model(
data_model, children=children)
if not member.name:

View File

@ -96,7 +96,7 @@ class PoolResponse(BasePoolType):
@classmethod
def from_data_model(cls, data_model, children=False):
pool = super(PoolResponse, cls).from_data_model(
pool = super().from_data_model(
data_model, children=children)
if data_model.session_persistence:
pool.session_persistence = (
@ -240,7 +240,7 @@ class PoolStatusResponse(BasePoolType):
@classmethod
def from_data_model(cls, data_model, children=False):
pool = super(PoolStatusResponse, cls).from_data_model(
pool = super().from_data_model(
data_model, children=children)
member_model = member.MemberStatusResponse

View File

@ -56,7 +56,7 @@ class QuotaResponse(base.BaseType):
@classmethod
def from_data_model(cls, data_model, children=False):
quotas = super(QuotaResponse, cls).from_data_model(
quotas = super().from_data_model(
data_model, children=children)
quotas.quota = QuotaBase.from_data_model(data_model)
return quotas
@ -83,7 +83,7 @@ class QuotaAllBase(base.BaseType):
@classmethod
def from_data_model(cls, data_model, children=False):
quotas = super(QuotaAllBase, cls).from_data_model(
quotas = super().from_data_model(
data_model, children=children)
# For backwards compatibility, remove in T
quotas.load_balancer = quotas.loadbalancer