Skip to content

Implement __bool__ for diskcache.Cache to make it Truthy #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

radiumatic
Copy link

Python first checks bool and then len to determine whether an object is Truthy. Given the fact that an empty cache returns 0 for the length, it breaks checks that rely on if cache instead of if cache is not None to detect whether it's initialized. This commit fixes the issue.

Python first checks __bool__ and then __len__ to determine whether an object is Truthy. Given the fact that an empty cache returns 0 for the length, it breaks checks that rely on `if cache` instead of `if cache is not None` to detect whether it's initialized. This commit fixes the issue.
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