Convert formatting to use ruff instead of yapf + isort (#26247)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -17,11 +17,13 @@ class SSLCertRefresher:
|
||||
reloads them when they change.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
ssl_context: SSLContext,
|
||||
key_path: Optional[str] = None,
|
||||
cert_path: Optional[str] = None,
|
||||
ca_path: Optional[str] = None) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
ssl_context: SSLContext,
|
||||
key_path: Optional[str] = None,
|
||||
cert_path: Optional[str] = None,
|
||||
ca_path: Optional[str] = None,
|
||||
) -> None:
|
||||
self.ssl = ssl_context
|
||||
self.key_path = key_path
|
||||
self.cert_path = cert_path
|
||||
@@ -36,8 +38,10 @@ class SSLCertRefresher:
|
||||
self.watch_ssl_cert_task = None
|
||||
if self.key_path and self.cert_path:
|
||||
self.watch_ssl_cert_task = asyncio.create_task(
|
||||
self._watch_files([self.key_path, self.cert_path],
|
||||
update_ssl_cert_chain))
|
||||
self._watch_files(
|
||||
[self.key_path, self.cert_path], update_ssl_cert_chain
|
||||
)
|
||||
)
|
||||
|
||||
# Setup CA files watcher
|
||||
def update_ssl_ca(change: Change, file_path: str) -> None:
|
||||
@@ -48,22 +52,21 @@ class SSLCertRefresher:
|
||||
self.watch_ssl_ca_task = None
|
||||
if self.ca_path:
|
||||
self.watch_ssl_ca_task = asyncio.create_task(
|
||||
self._watch_files([self.ca_path], update_ssl_ca))
|
||||
self._watch_files([self.ca_path], update_ssl_ca)
|
||||
)
|
||||
|
||||
async def _watch_files(self, paths, fun: Callable[[Change, str],
|
||||
None]) -> None:
|
||||
async def _watch_files(self, paths, fun: Callable[[Change, str], None]) -> None:
|
||||
"""Watch multiple file paths asynchronously."""
|
||||
logger.info("SSLCertRefresher monitors files: %s", paths)
|
||||
async for changes in awatch(*paths):
|
||||
try:
|
||||
for change, file_path in changes:
|
||||
logger.info("File change detected: %s - %s", change.name,
|
||||
file_path)
|
||||
logger.info("File change detected: %s - %s", change.name, file_path)
|
||||
fun(change, file_path)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
"SSLCertRefresher failed taking action on file change. "
|
||||
"Error: %s", e)
|
||||
"SSLCertRefresher failed taking action on file change. Error: %s", e
|
||||
)
|
||||
|
||||
def stop(self) -> None:
|
||||
"""Stop watching files."""
|
||||
|
||||
Reference in New Issue
Block a user