QTZPOC-20

QTZPOC-20: Remove redundant NOSONAR comments across multiple files.
This commit is contained in:
2026-09-10 09:39:21 -03:00
parent 9e0da03717
commit e600c7922e
6 changed files with 18 additions and 18 deletions

View File

@@ -25,7 +25,7 @@ def build_mlflow_config() -> dict[str, Any]:
'host': getenv('MLFLOW_HOST', 'http://localhost'), 'host': getenv('MLFLOW_HOST', 'http://localhost'),
'port': int(getenv('MLFLOW_PORT', '5080')), 'port': int(getenv('MLFLOW_PORT', '5080')),
'username': getenv('MLFLOW_USERNAME', 'aignosi'), 'username': getenv('MLFLOW_USERNAME', 'aignosi'),
'password': getenv('MLFLOW_PASSWORD', 'aignosi'), # NOSONAR 'password': getenv('MLFLOW_PASSWORD', 'aignosi'),
} }

View File

@@ -342,7 +342,7 @@ def summarize_failure(
""" """
if exception is not None: if exception is not None:
cause = _root_cause(exception) cause = _root_cause(exception)
return _type_name(cause), _one_line(str(cause)) # NOSONAR return _type_name(cause), _one_line(str(cause))
return error_type or _UNKNOWN_ERROR_TYPE, _one_line(detail_text or '') return error_type or _UNKNOWN_ERROR_TYPE, _one_line(detail_text or '')
@@ -361,8 +361,8 @@ def describe_failure_chain(exception: BaseException) -> tuple[str, str]:
""" """
links: list[str] = [] links: list[str] = []
for candidate in walk_cause_chain(exception): for candidate in walk_cause_chain(exception):
kind = _type_name(candidate) # NOSONAR kind = _type_name(candidate)
message = _one_line(str(candidate)) # NOSONAR message = _one_line(str(candidate))
# `ApplicationError.__str__` already prefixes its own type, and `MlflowException: # `ApplicationError.__str__` already prefixes its own type, and `MlflowException:
# MlflowException: …` reads like two failures rather than one. # MlflowException: …` reads like two failures rather than one.
if not message: if not message:
@@ -422,7 +422,7 @@ def failure_location(exception: BaseException | None) -> tuple[str | None, int |
if exception is None: if exception is None:
return None, None return None, None
for candidate in walk_cause_chain(exception): for candidate in walk_cause_chain(exception):
details = getattr(candidate, 'details', None) # NOSONAR details = getattr(candidate, 'details', None)
if details and isinstance(details[0], dict) and 'step' in details[0]: if details and isinstance(details[0], dict) and 'step' in details[0]:
location = details[0] location = details[0]
gate = location.get('gate') gate = location.get('gate')

View File

@@ -1150,7 +1150,7 @@ class MLFlowRepository(SientiaMonitoring):
prediction_data.index = input_index prediction_data.index = input_index
# Merge prediction data with retrain_dataset on index # Merge prediction data with retrain_dataset on index
prediction_data = pd.merge( # NOSONAR prediction_data = pd.merge(
retrain_dataset, prediction_data, left_index=True, right_index=True, how='left' retrain_dataset, prediction_data, left_index=True, right_index=True, how='left'
) )
@@ -1275,7 +1275,7 @@ class MLFlowRepository(SientiaMonitoring):
# Aligns data with treated data indexes to get target variable # Aligns data with treated data indexes to get target variable
aligned_data = data.loc[treated_data.index] aligned_data = data.loc[treated_data.index]
aligned_series = aligned_data[target_name] aligned_series = aligned_data[target_name]
retrain_dataset = pd.merge( # NOSONAR retrain_dataset = pd.merge(
treated_data, aligned_series, left_index=True, right_index=True treated_data, aligned_series, left_index=True, right_index=True
) )
else: else:

View File

@@ -79,7 +79,7 @@ def _opc_authentication_token_str(client: Client | None) -> str:
if tok is None: if tok is None:
return 'unknown' return 'unknown'
return str(tok) return str(tok)
except Exception: # NOSONAR - best-effort label for logs/metrics, must not fail loud except Exception: # best-effort label for logs/metrics, must not fail loud
return 'unknown' return 'unknown'
@@ -94,8 +94,8 @@ def _opc_status_from_exception(exc: BaseException) -> str:
str: Status class name or generic Python exception name. str: Status class name or generic Python exception name.
""" """
for candidate in walk_cause_chain(exc): for candidate in walk_cause_chain(exc):
if isinstance(candidate, UaStatusCodeError): # NOSONAR if isinstance(candidate, UaStatusCodeError):
return type(candidate).__name__ # NOSONAR return type(candidate).__name__
return type(exc).__name__ return type(exc).__name__

View File

@@ -305,7 +305,7 @@ async def main():
# This will run the workers and wait for them to complete. # This will run the workers and wait for them to complete.
# If an exception occurs in any of the worker handlers, it will be propagated here. # If an exception occurs in any of the worker handlers, it will be propagated here.
await asyncio.gather(*handlers) await asyncio.gather(*handlers)
except BaseException as e: # NOSONAR except BaseException as e:
logger.custom_error(f'An unhandled exception occurred: {e}', metadata) logger.custom_error(f'An unhandled exception occurred: {e}', metadata)
exit_code = 1 exit_code = 1
finally: finally:

View File

@@ -227,7 +227,7 @@ class ImportModel:
'version': version['version'], 'version': version['version'],
'document_id': document.get('id'), 'document_id': document.get('id'),
} }
except BaseException as error: # NOSONAR - classified once below, then re-raised untouched except BaseException as error: # classified once below, then re-raised untouched
located_step, located_gate = failure_location(error) located_step, located_gate = failure_location(error)
step = located_step or step step = located_step or step
gate = located_gate gate = located_gate
@@ -309,7 +309,7 @@ class ImportModel:
retry_policy=IMPORT_STATUS_HINT_RETRY_POLICY, retry_policy=IMPORT_STATUS_HINT_RETRY_POLICY,
start_to_close_timeout=STATUS_WRITE_TIMEOUT, start_to_close_timeout=STATUS_WRITE_TIMEOUT,
) )
except BaseException as error: # NOSONAR - a lost hint must not fail a working import except BaseException as error: # a lost hint must not fail a working import
if is_cancelled_exception(error): if is_cancelled_exception(error):
raise raise
await self._report_status_write_failure(base, error) await self._report_status_write_failure(base, error)
@@ -346,7 +346,7 @@ class ImportModel:
) )
except ( except (
BaseException BaseException
) as error: # NOSONAR - the outcome stands even when it cannot be written ) as error: # the outcome stands even when it cannot be written
if is_cancelled_exception(error): if is_cancelled_exception(error):
raise raise
await self._report_status_write_failure( await self._report_status_write_failure(
@@ -382,7 +382,7 @@ class ImportModel:
retry_policy=IMPORT_STATUS_HINT_RETRY_POLICY, retry_policy=IMPORT_STATUS_HINT_RETRY_POLICY,
start_to_close_timeout=STATUS_WRITE_TIMEOUT, start_to_close_timeout=STATUS_WRITE_TIMEOUT,
) )
except BaseException as error: # NOSONAR - the report of a report is where this stops except BaseException as error: # the report of a report is where this stops
if is_cancelled_exception(error): if is_cancelled_exception(error):
raise raise
@@ -400,7 +400,7 @@ class ImportModel:
retry_policy=retry_policy, retry_policy=retry_policy,
start_to_close_timeout=STATUS_WRITE_TIMEOUT, start_to_close_timeout=STATUS_WRITE_TIMEOUT,
) )
except BaseException as error: # NOSONAR - the report of a report is where this stops except BaseException as error: # the report of a report is where this stops
if is_cancelled_exception(error): if is_cancelled_exception(error):
raise raise
# Deliberately silent otherwise: the channel this was trying to reach is the thing that # Deliberately silent otherwise: the channel this was trying to reach is the thing that
@@ -426,7 +426,7 @@ class ImportModel:
retry_policy=retry_policy, retry_policy=retry_policy,
start_to_close_timeout=RETENTION_TIMEOUT, start_to_close_timeout=RETENTION_TIMEOUT,
) )
except BaseException as error: # NOSONAR - retention is not a precondition of an import except BaseException as error: # retention is not a precondition of an import
if is_cancelled_exception(error): if is_cancelled_exception(error):
raise raise
# Dropped, not reported otherwise: the activity's own failure is already in the event # Dropped, not reported otherwise: the activity's own failure is already in the event
@@ -446,7 +446,7 @@ class ImportModel:
) )
except ( except (
BaseException BaseException
) as error: # NOSONAR - cleanup never replaces the failure that brought us here ) as error: # cleanup never replaces the failure that brought us here
if is_cancelled_exception(error): if is_cancelled_exception(error):
raise raise
return {'cleaned': False} return {'cleaned': False}