Merge "Run pyupgrade to clean up Python 2 syntaxes"
This commit is contained in:
commit
ceda3957b2
@ -28,3 +28,8 @@ repos:
|
||||
hooks:
|
||||
- id: bandit
|
||||
args: ['-x', 'tests']
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.18.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py3-only]
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2020 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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
|
||||
@ -35,10 +33,10 @@ class ProjectOverLimit(Exception):
|
||||
msg = _("Project %(project_id)s is over a limit for "
|
||||
"%(limits)s") % {'project_id': project_id,
|
||||
'limits': over_limit_info_list}
|
||||
super(ProjectOverLimit, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class OverLimitInfo(object):
|
||||
class OverLimitInfo:
|
||||
def __init__(self, resource_name, limit, current_usage, delta):
|
||||
self.resource_name = resource_name
|
||||
self.limit = int(limit)
|
||||
@ -60,4 +58,4 @@ class SessionInitError(Exception):
|
||||
msg = _(
|
||||
"Can't initialise OpenStackSDK session: %(reason)s."
|
||||
) % {'reason': reason}
|
||||
super(SessionInitError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
@ -37,7 +37,7 @@ class LimitFixture(fixtures.Fixture):
|
||||
self.projlimits = projlimits
|
||||
|
||||
def setUp(self):
|
||||
super(LimitFixture, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
# We mock our own cached connection to Keystone
|
||||
self.mock_conn = mock.MagicMock()
|
||||
|
@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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
|
||||
@ -55,7 +53,7 @@ def _get_keystone_connection():
|
||||
return _SDK_CONNECTION
|
||||
|
||||
|
||||
class Enforcer(object):
|
||||
class Enforcer:
|
||||
|
||||
def __init__(self, usage_callback, cache=True):
|
||||
"""An object for checking usage against resource limits and requests.
|
||||
@ -190,7 +188,7 @@ class Enforcer(object):
|
||||
resources_to_check)
|
||||
|
||||
|
||||
class _FlatEnforcer(object):
|
||||
class _FlatEnforcer:
|
||||
|
||||
name = 'flat'
|
||||
|
||||
@ -221,7 +219,7 @@ class _FlatEnforcer(object):
|
||||
current_usage, deltas)
|
||||
|
||||
|
||||
class _StrictTwoLevelEnforcer(object):
|
||||
class _StrictTwoLevelEnforcer:
|
||||
|
||||
name = 'strict-two-level'
|
||||
|
||||
@ -246,13 +244,13 @@ _MODELS = [_FlatEnforcer, _StrictTwoLevelEnforcer]
|
||||
|
||||
class _LimitNotFound(Exception):
|
||||
def __init__(self, resource):
|
||||
msg = "Can't find the limit for resource %(resource)s" % {
|
||||
'resource': resource}
|
||||
msg = "Can't find the limit for resource {resource}".format(
|
||||
resource=resource)
|
||||
self.resource = resource
|
||||
super(_LimitNotFound, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class _EnforcerUtils(object):
|
||||
class _EnforcerUtils:
|
||||
"""Logic common used by multiple enforcers"""
|
||||
|
||||
def __init__(self, cache=True):
|
||||
|
@ -26,7 +26,7 @@ CONF = cfg.CONF
|
||||
|
||||
class TestFixture(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestFixture, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
|
||||
self.config_fixture.config(
|
||||
|
@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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
|
||||
@ -42,7 +40,7 @@ CONF = cfg.CONF
|
||||
class TestEnforcer(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestEnforcer, self).setUp()
|
||||
super().setUp()
|
||||
self.deltas = dict()
|
||||
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
|
||||
self.config_fixture.config(
|
||||
@ -229,7 +227,7 @@ class TestEnforcer(base.BaseTestCase):
|
||||
|
||||
class TestFlatEnforcer(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestFlatEnforcer, self).setUp()
|
||||
super().setUp()
|
||||
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
|
||||
self.config_fixture.config(
|
||||
group='oslo_limit',
|
||||
@ -322,7 +320,7 @@ class TestFlatEnforcer(base.BaseTestCase):
|
||||
|
||||
class TestEnforcerUtils(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestEnforcerUtils, self).setUp()
|
||||
super().setUp()
|
||||
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
|
||||
self.config_fixture.config(
|
||||
group='oslo_limit',
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2020 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
Loading…
Reference in New Issue
Block a user