From 89a24c8aaacf5f5d8dec20477e26dc62a33e628f Mon Sep 17 00:00:00 2001 From: Jeff Casavant Date: Wed, 23 Mar 2022 16:52:48 -0400 Subject: [PATCH] Fix is_set to return True for falsy values inside dictionaries Signed-off-by: Jeff Casavant --- tests/test_vyper.py | 7 +++++++ vyper/vyper.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_vyper.py b/tests/test_vyper.py index 7016a4e..19e8dac 100644 --- a/tests/test_vyper.py +++ b/tests/test_vyper.py @@ -25,6 +25,10 @@ yaml_example = """Hacker: true name: steve +pets: + count: 0 + names: [] + preferred_veterinarian: '' hobbies: - skateboarding - snowboarding @@ -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")) diff --git a/vyper/vyper.py b/vyper/vyper.py index d365251..ed9c67d 100644 --- a/vyper/vyper.py +++ b/vyper/vyper.py @@ -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::])