Skip to content

Commit

Permalink
Fix is_set to return True for falsy values inside dictionaries
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Casavant <[email protected]>
  • Loading branch information
Jeff Casavant committed Mar 23, 2022
1 parent 56f7dfd commit 89a24c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/test_vyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

yaml_example = """Hacker: true
name: steve
pets:
count: 0
names: []
preferred_veterinarian: ''
hobbies:
- skateboarding
- snowboarding
Expand Down Expand Up @@ -430,6 +434,9 @@ def test_unmarshall(self):
def test_is_set(self):
self.v.set_config_type("yaml")
self.v.read_config(yaml.safe_dump(text(yaml_example)))
self.assertTrue(self.v.is_set("pets.count"))
self.assertTrue(self.v.is_set("pets.names"))
self.assertTrue(self.v.is_set("pets.preferred_veterinarian"))
self.assertTrue(self.v.is_set("clothing.jacket"))
self.assertFalse(self.v.is_set("clothing.jackets"))
self.assertFalse(self.v.is_set("helloworld"))
Expand Down
2 changes: 1 addition & 1 deletion vyper/vyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _search_dict(self, d, keys):
return d
for key in keys:
val = self._find_insensitive(key, d)
if val and not isinstance(val, dict):
if val is not None and not isinstance(val, dict):
return val
elif val:
return self._search_dict(val, keys[1::])
Expand Down

0 comments on commit 89a24c8

Please sign in to comment.