fix: explicitly type LOGGER as logging.Logger in log.py#5711
Closed
sarthak-here wants to merge 3 commits into
Closed
fix: explicitly type LOGGER as logging.Logger in log.py#5711sarthak-here wants to merge 3 commits into
sarthak-here wants to merge 3 commits into
Conversation
logging.getLogger() never returns None, so LOGGER should be annotated as logging.Logger rather than left unannotated or marked Optional. This resolves the mypy type error without pushing Optional checks to every callsite that uses LOGGER. Fixes ossf#2870 Signed-off-by: sarthak-here <sarthak909999@gmail.com>
sarthak-here
force-pushed
the
fix/logger-type-annotation
branch
from
April 19, 2026 16:53
2db8441 to
bcfc2bf
Compare
Author
|
hey can anyone check it out and see if i can merge it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Closes #2870
LOGGERincve_bin_tool/log.pyhad no explicit type annotation, which caused mypy to raise"cve_bin_tool.log.LOGGER is not a valid type".Why not
Optional[logging.Logger]The two existing PRs (#5665, #5666) annotate
LOGGERasOptional[logging.Logger], butlogging.getLogger()never returnsNone— it always returns aLoggerinstance. Marking itOptionalwould push unnecessary null-checks to every callsite that imports and usesLOGGER.The fix
A single non-optional annotation that accurately reflects what
getLogger()returns.Testing