Skip to content
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

Secret: add a __bool__ implementation #1625

Merged
merged 1 commit into from
May 5, 2022
Merged

Conversation

rcoup
Copy link
Contributor

@rcoup rcoup commented May 5, 2022

Allows using a Secrets in a conditional statement to check for empty/None without needing to cast it to a str.

Before:

if str(settings.A_SECRET):  # without the cast it's always True
  # do stuff

After:

if settings.A_SECRET:
  # do stuff

Allows using `if settings.A_SECRET:` to check for empty/None without needing to
cast it to a str.
@Kludex Kludex added the feature New feature or request label May 5, 2022
@Kludex
Copy link
Sponsor Member

Kludex commented May 5, 2022

Thanks for the PR @rcoup !

@Kludex Kludex merged commit beb8943 into encode:master May 5, 2022
@rcoup rcoup deleted the rc-secret-bool branch May 6, 2022 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants