Skip to content

Reject bool for retention, rotation, level, and handler ids - #1514

Open
Pitchfork-and-Torch wants to merge 1 commit into
Delgan:masterfrom
Pitchfork-and-Torch:cook/reject-bool-retention-rotation-level
Open

Pitchfork-and-Torch wants to merge 1 commit into
Delgan:masterfrom
Pitchfork-and-Torch:cook/reject-bool-retention-rotation-level

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

bool subclasses int and numbers.Real, so several Loguru APIs treated booleans as numbers:

  • retention=True → keep 1 file (False → keep 0)
  • rotation=True → rotate at 1 byte
  • logger.level(..., no=True) → severity 1
  • logger.remove(True) → remove handler id 1
  • logger.add(..., level=True) / logger.log(True, ...) → severity 1

This raises TypeError for bool on those paths while still accepting real integers (retention=0, level=10, etc.).

Test plan

  • New tests in tests/test_bool_numeric_rejection.py (13 passed)
  • Integer retention/rotation/level values still accepted

bool subclasses int and numbers.Real, so retention=True kept 1 file,
rotation=True used a 1-byte size limit, level(no=True) set severity 1,
remove(True) removed handler id 1, and add(level=True) filtered at 1.
Raise TypeError for bool so callers pass an explicit integer.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant