Conversation
There was a problem hiding this comment.
Pull request overview
This PR refines the return type hint for LevelConfigPM._check_level and bumps the potato_util dependency version used by the logging configuration layer.
Changes:
- Narrow
_check_levelreturn type fromAnytostr | int | LogLevelEnum. - Bump
potato_utilrequirement from>=0.3.0to>=0.3.1.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/beans_logging/config.py |
Tightens _check_level type hint for log level validation. |
requirements.txt |
Updates potato_util minimum version. |
Comments suppressed due to low confidence (1)
src/beans_logging/config.py:108
- In
_check_level, the debug-mode override only exemptsLogLevelEnum.TRACEand integer5. If callers pass the level as the string "TRACE" (which is supported elsewhere), this condition will still evaluate true and the value will be forced toLogLevelEnum.DEBUG, preventing TRACE from being respected in debug mode. Consider normalizing string inputs toLogLevelEnum(or explicitly treating "TRACE"/"5" as TRACE) before this comparison so user-provided TRACE values behave consistently.
def _check_level(cls, val: Any) -> str | int | LogLevelEnum:
if not isinstance(val, (str, int, LogLevelEnum)):
raise TypeError(
f"Level attribute type {type(val).__name__} is invalid, must be str, int or <LogLevelEnum>!"
)
if utils.is_debug_mode() and (val != LogLevelEnum.TRACE) and (val != 5):
val = LogLevelEnum.DEBUG
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request makes a minor improvement to the type hint for the
_check_levelclass method in theLevelConfigPMclass. The new type hint clarifies that the method can return a value of typestr,int, orLogLevelEnum.