-
Notifications
You must be signed in to change notification settings - Fork 25
Drop redundant exception interpolation in logger.exception(...) calls #647
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestpriority:lowNice-to-have improvement. Can be deferred without blocking other work.Nice-to-have improvement. Can be deferred without blocking other work.pythonPull requests that update Python codePull requests that update Python codepython:idiomsRefactors toward idiomatic Python (PEP conventions, stdlib idioms)Refactors toward idiomatic Python (PEP conventions, stdlib idioms)
Description
Activity
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestpriority:lowNice-to-have improvement. Can be deferred without blocking other work.Nice-to-have improvement. Can be deferred without blocking other work.pythonPull requests that update Python codePull requests that update Python codepython:idiomsRefactors toward idiomatic Python (PEP conventions, stdlib idioms)Refactors toward idiomatic Python (PEP conventions, stdlib idioms)
Problem
services/player_service.pylogs caught exceptions like this (threeoccurrences, in
create_async,update_by_squad_number_async,delete_by_squad_number_async):Logger.exception()already attaches the active exception — type, message, andfull traceback — to the log record. Interpolating
errorwith%sduplicatesthe message text and adds noise. The idiomatic call passes only the static
message.
Proposed Solution
The
logger.error("Player not found for update: squad_number=%s", squad_number)calls are correct as-is — there is no active exceptionthere, and they interpolate data, not an exception.
Suggested Approach
except SQLAlchemyError as error:block that callslogger.exception(...), drop theas errorbinding and the: %s/, errorargument.logger.error(...)data-interpolation calls untouched.tools/seed_*.pyhas the samelogger.exception("...: %s", exc)pattern —fix there too if convenient (lower priority;
tools/is legacy).uv run pytest.Acceptance Criteria
logger.exception()calls carry a static message, no exception%sas errorbindings removedlogger.error(...)data-interpolation calls unchangedCHANGELOG.mdupdatedReferences
logging.Logger.exception