Repository navigation
python: Test optional values against None explicitly - #297
Closed
daandemeyer wants to merge 1 commit into
Closed
daandemeyer wants to merge 1 commit into
daandemeyer wants to merge 1 commit into
Conversation
ty 0.0.86 reports every truthiness test of an optional str, bytes, int or list as an error. A truthiness test treats None and an empty value the same way. Compare against None where the value is never empty. Give environment lookups an empty default where an empty variable means unset. Take the rpm driver's languages and cache seeds as a sequence that defaults to empty, because an empty list already meant the same as None there. Signed-off-by: Daan De Meyer <daan@amutable.com>
martinpitt
reviewed
Oct 12, 2026
| """ | ||
| named = _digest(str(store.resolve())) | ||
| runtime = os.environ.get("XDG_RUNTIME_DIR") | ||
| runtime = os.environ.get("XDG_RUNTIME_DIR", "") |
Member
There was a problem hiding this comment.
FTR: That's the kind of "pointless noise" why I disabled that new rule in #293. a default of "" for a directory does not make any sense semantically, so a clean fix would have to do is not None rather.
The "fals-y" concept is pretty deeply woven into Python, so I find the new rule overzealous for most purposes.
martinpitt
reviewed
Oct 12, 2026
| subcommand=subcommand, | ||
| # The flag's own fallback, which Buck honors wherever the flag may appear. | ||
| isolation=isolation or os.environ.get("BUCK_ISOLATION_DIR"), | ||
| isolation=isolation or os.environ.get("BUCK_ISOLATION_DIR") or None, |
Member
There was a problem hiding this comment.
this is also stupid noise IMHO. .get() already returns None as a default.
Member
Author
|
Sure, I opened two new PRs for the two findings that are actually bugs |
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.
ty 0.0.86 reports every truthiness test of an optional str, bytes, int or
list as an error. A truthiness test treats None and an empty value the same
way. Compare against None where the value is never empty. Give environment
lookups an empty default where an empty variable means unset. Take the rpm
driver's languages and cache seeds as a sequence that defaults to empty,
because an empty list already meant the same as None there.
Signed-off-by: Daan De Meyer daan@amutable.com