Remove ruff ignores

Only the assert check is kept since we will use this in the future when
working on typing.

Change-Id: I19ebe5e0761d7b1f820335caf5def1034c588dce
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane committed 2026-10-01 10:32:48 +01:00
1 parent 831f8f1226
commit 7006b74830
10 files changed
+20 -28

No files matched your search

+5 -5
View File
@@ -99,7 +99,7 @@ def init_backend(type_: BackendType) -> None:
return # already initialized with same value; no-op
backend_name = type_.value
LOG.info(f"Loading backend: {backend_name}")
LOG.info("Loading backend: %s", backend_name)
try:
module_name = f"oslo_service.backend._{backend_name}"
@@ -110,15 +110,15 @@ def init_backend(type_: BackendType) -> None:
_cached_backend = new_backend = backend_class()
except ModuleNotFoundError:
LOG.error(f"Backend module {module_name} not found.")
LOG.error("Backend module %s not found.", module_name)
raise ValueError(f"Unknown backend: {backend_name!r}")
except AttributeError:
LOG.error(f"Backend class not found in module {module_name}.")
LOG.error("Backend class not found in module %s.", module_name)
raise ImportError(f"Backend class not found in module {module_name}")
_cached_backend_type = type_
_cached_components = new_backend.get_service_components()
LOG.info(f"Backend {type_.value!r} successfully loaded and cached.")
LOG.info("Backend %r successfully loaded and cached.", type_.value)
def get_backend() -> BaseBackend:
@@ -130,7 +130,7 @@ def get_backend() -> BaseBackend:
if _backend_hook is not None:
try:
type_ = _backend_hook()
LOG.info(f"Backend hook selected: {type_.value}")
LOG.info("Backend hook selected: %s", type_.value)
except Exception:
LOG.exception(
"Backend hook raised an exception."
+1 -2
View File
@@ -68,10 +68,9 @@ def _safe_wrapper(f, kind, func_name):
except LoopingCallDone:
raise # let the outer handler process this
except Exception:
LOG.error(
LOG.exception(
'%(kind)s %(func_name)r failed',
{'kind': kind, 'func_name': func_name},
exc_info=True,
)
return 0
+1 -1
View File
@@ -45,7 +45,7 @@ class EventletBackend(BaseBackend):
"LoopingCallDone": loopingcall.LoopingCallDone,
"LoopingCallTimeOut": loopingcall.LoopingCallTimeOut,
"FixedIntervalLoopingCall": loopingcall.FixedIntervalLoopingCall,
"FixedIntervalWithTimeoutLoopingCall": loopingcall.FixedIntervalWithTimeoutLoopingCall,
"FixedIntervalWithTimeoutLoopingCall": loopingcall.FixedIntervalWithTimeoutLoopingCall, # noqa: E501
"DynamicLoopingCall": loopingcall.DynamicLoopingCall,
"BackOffLoopingCall": loopingcall.BackOffLoopingCall,
"RetryDecorator": loopingcall.RetryDecorator,
+1 -1
View File
@@ -43,7 +43,7 @@ class ThreadingBackend(BaseBackend):
"LoopingCallDone": loopingcall.LoopingCallDone,
"LoopingCallTimeOut": loopingcall.LoopingCallTimeOut,
"FixedIntervalLoopingCall": loopingcall.FixedIntervalLoopingCall,
"FixedIntervalWithTimeoutLoopingCall": loopingcall.FixedIntervalWithTimeoutLoopingCall,
"FixedIntervalWithTimeoutLoopingCall": loopingcall.FixedIntervalWithTimeoutLoopingCall, # noqa: E501
"DynamicLoopingCall": loopingcall.DynamicLoopingCall,
"BackOffLoopingCall": loopingcall.BackOffLoopingCall,
"RetryDecorator": loopingcall.RetryDecorator,
+5 -5
View File
@@ -44,10 +44,9 @@ def _check_spawn_picklable(service_instance, conf=None):
if conf is not None:
ForkingPickler.dumps(conf)
except Exception:
LOG.error(
LOG.exception(
"Service %s or its ConfigOpts is not serializable with spawn.",
type(service_instance).__name__,
exc_info=True,
)
raise
@@ -65,7 +64,8 @@ def _select_service_manager_context(
available_methods = multiprocessing.get_all_start_methods()
if start_method not in (None, "fork", "spawn"):
raise ValueError(
f"Invalid start_method {start_method!r}; expected 'fork' or 'spawn'"
f"Invalid start_method {start_method!r}; "
f"expected 'fork' or 'spawn'"
)
selected_method = start_method
@@ -74,8 +74,8 @@ def _select_service_manager_context(
if selected_method not in available_methods:
raise ValueError(
f"Multiprocessing start method {selected_method!r} is not available on this "
"platform"
f"Multiprocessing start method {selected_method!r} is not "
f"available on this platform"
)
if selected_method == "spawn":
+2 -3
View File
@@ -215,7 +215,7 @@ def _nearest_boundary(last_run, spacing):
delta = current_time - last_run
offset = delta % spacing
# Add up to 5% jitter
jitter = int(spacing * (random.random() / 20)) # nosec
jitter = int(spacing * (random.random() / 20)) # noqa: S311
return current_time - offset + jitter
@@ -350,12 +350,11 @@ class PeriodicTasks(metaclass=_PeriodicTasksMeta):
ForkingPickler.dumps(self)
ForkingPickler.dumps(context)
except Exception:
LOG.error(
LOG.exception(
"%(class)s or context is not picklable with spawn. "
"The PeriodicTasks instance and context must be spawn-safe "
"for parallel periodic tasks.",
{"class": type(self).__name__},
exc_info=True,
)
raise
for full_task_name, task_name, task, next_run in due_tasks:
+1 -5
View File
@@ -142,11 +142,7 @@ class LoopingCallTestCase(test_base.BaseTestCase):
expected = expected_calls[i]
args, kwargs = call
actual = args[0]
message = 'Call #%d, expected: %s, actual: %s' % (
i,
expected,
actual,
)
message = f'Call #{i}, expected: {expected}, actual: {actual}'
self.assertAlmostEqual(expected, actual, message=message)
def test_looping_call_timed_out(self):
+2 -2
View File
@@ -221,14 +221,14 @@ class TestWSGIServer(WsgiTestCase):
server.start()
self.assertFalse(server._server.dead)
uri = "http://127.0.0.1:%d/%s" % (server.port, 10000 * 'x')
uri = "http://127.0.0.1:{}/{}".format(server.port, 10000 * 'x')
resp = requests.get(uri, proxies={"http": ""})
eventlet.sleep(0)
self.assertNotEqual(
requests.codes.REQUEST_URI_TOO_LARGE, resp.status_code
)
uri = "http://127.0.0.1:%d/%s" % (server.port, 20000 * 'x')
uri = "http://127.0.0.1:{}/{}".format(server.port, 20000 * 'x')
resp = requests.get(uri, proxies={"http": ""})
eventlet.sleep(0)
self.assertEqual(
+2 -2
View File
@@ -95,8 +95,8 @@ class Server(service.ServiceBase):
conf,
name,
app,
host='0.0.0.0',
port=0, # nosec
host='0.0.0.0', # noqa: S104
port=0,
pool_size=None,
protocol=eventlet.wsgi.HttpProtocol,
backlog=128,
-2
View File
@@ -59,8 +59,6 @@ select = ["E", "F", "G", "LOG", "S", "UP"]
external = ["H"]
ignore = [
"S101", # asserts are only used for type narrowing
# FIXME(stephenfin): Remove all the below exceptions
"S104", "S311", "UP031", "G004", "G201", "E501",
]
[tool.ruff.lint.per-file-ignores]