Skip to content

Reject bool for Cache timeout and expire - #376

Open
Pitchfork-and-Torch wants to merge 1 commit into
grantjenks:masterfrom
Pitchfork-and-Torch:cook/reject-bool-expire-timeout
Open

Pitchfork-and-Torch wants to merge 1 commit into
grantjenks:masterfrom
Pitchfork-and-Torch:cook/reject-bool-expire-timeout

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

bool subclasses int, so:

  • Cache(..., timeout=True) silently became a 1s SQLite timeout
  • cache.set/add/touch(..., expire=True) silently became a 1s TTL
  • expire=False became now + 0 (immediate expiry)

This raises TypeError when a bool is passed for timeout / expire, while still accepting numeric values.

Test plan

  • New tests in tests/test_bool_expire_timeout.py (9 passed)
  • expire=5 / touch(..., expire=10) still work

bool subclasses int, so timeout=True became a 1s SQLite timeout and
expire=True/False became a 1s TTL or immediate expiry (now+0).
Raise TypeError for bool so callers pass an explicit numeric value.
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