Skip to content

Commit

Permalink
Apply ruff, ruff-format
Browse files Browse the repository at this point in the history
We disable the E203 (whitespace before ':') and E501 (line too long)
linter rules since these conflict with ruff-format. We also rework a
statement in 'keystoneauth1/tests/unit/test_session.py' since it's
triggering a bug in flake8 [1] that is currently (at time of authoring)
unresolved.

[1] PyCQA/flake8#1948

Signed-off-by: Stephen Finucane <[email protected]>
Change-Id: Ief5c1c57d1e72db9fc881063d4c7e1030e76da43
  • Loading branch information
stephenfin committed Sep 11, 2024
1 parent c05e237 commit 127d7be
Show file tree
Hide file tree
Showing 137 changed files with 8,999 additions and 6,392 deletions.
6 changes: 3 additions & 3 deletions doc/ext/list_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ListAuthPluginsDirective(rst.Directive):
has_content = True

def report_load_failure(mgr, ep, err):
LOG.warning(u'Failed to load %s: %s' % (ep.module_name, err))
LOG.warning(f'Failed to load {ep.module_name}: {err}')

def display_plugin(self, ext):
overline_style = self.options.get('overline-style', '')
Expand All @@ -60,15 +60,15 @@ def display_plugin(self, ext):
yield "\n"

for opt in ext.obj.get_options():
yield ":%s: %s" % (opt.name, opt.help)
yield f":{opt.name}: {opt.help}"

yield "\n"

def run(self):
mgr = extension.ExtensionManager(
'keystoneauth1.plugin',
on_load_failure_callback=self.report_load_failure,
invoke_on_load=True,
invoke_on_load=True,
)

result = ViewList()
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
'Openstack Developers',
'manual',
True,
),
)
]

# Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664
Expand Down
2 changes: 1 addition & 1 deletion keystoneauth1/_fair_semaphore.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import time


class FairSemaphore(object):
class FairSemaphore:
"""Semaphore class that notifies in order of request.
We cannot use a normal Semaphore because it doesn't give any ordering,
Expand Down
4 changes: 2 additions & 2 deletions keystoneauth1/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def before_utcnow(**timedelta_kwargs):

# Detect if running on the Windows Subsystem for Linux
try:
with open('/proc/version', 'r') as f:
with open('/proc/version') as f:
is_windows_linux_subsystem = 'microsoft' in f.read().lower()
except IOError:
except OSError:
is_windows_linux_subsystem = False
10 changes: 6 additions & 4 deletions keystoneauth1/access/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from keystoneauth1.access.access import * # noqa


__all__ = ('AccessInfo', # noqa: F405
'AccessInfoV2', # noqa: F405
'AccessInfoV3', # noqa: F405
'create') # noqa: F405
__all__ = ( # noqa: F405
'AccessInfo',
'AccessInfoV2',
'AccessInfoV3',
'create',
)
16 changes: 7 additions & 9 deletions keystoneauth1/access/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
STALE_TOKEN_DURATION = 30


__all__ = ('AccessInfo',
'AccessInfoV2',
'AccessInfoV3',
'create')
__all__ = ('AccessInfo', 'AccessInfoV2', 'AccessInfoV3', 'create')


def create(resp=None, body=None, auth_token=None):
Expand All @@ -47,7 +44,6 @@ def create(resp=None, body=None, auth_token=None):


def _missingproperty(f):

@functools.wraps(f)
def inner(self):
try:
Expand All @@ -58,7 +54,7 @@ def inner(self):
return property(inner)


class AccessInfo(object):
class AccessInfo:
"""Encapsulates a raw authentication token from keystone.
Provides helper methods for extracting useful values from that token.
Expand All @@ -77,7 +73,8 @@ def __init__(self, body, auth_token=None):
def service_catalog(self):
if not self._service_catalog:
self._service_catalog = self._service_catalog_class.from_token(
self._data)
self._data
)

return self._service_catalog

Expand Down Expand Up @@ -422,7 +419,7 @@ def has_service_catalog(self):

@_missingproperty
def auth_token(self):
set_token = super(AccessInfoV2, self).auth_token
set_token = super().auth_token
return set_token or self._data['access']['token']['id']

@property
Expand Down Expand Up @@ -775,7 +772,8 @@ def audit_chain_id(self):
def service_providers(self):
if not self._service_providers:
self._service_providers = (
service_providers.ServiceProviders.from_token(self._data))
service_providers.ServiceProviders.from_token(self._data)
)

return self._service_providers

Expand Down
Loading

0 comments on commit 127d7be

Please sign in to comment.