canonical / juju-verify

https://launchpad.net/juju-verify
GNU General Public License v3.0
2 stars 7 forks source link

Result: add __bool__ function #126

Closed esunar closed 2 years ago

esunar commented 2 years ago

We can add the __bool__ function to the Result class as a fauture for use in a logic condition.

def __bool__(self):
    return not self.empty

Than we can use it like this:

return result or Result(Severity.OK, 'Minimum juju version check passed.')

instead of this:

if result.empty:
    result.add_partial_result(Severity.OK, 'Minimum juju version check passed.')

return result

Imported from Launchpad using lp2gh.

esunar commented 2 years ago

(by rgildein) PR: https://github.com/canonical/juju-verify/pull/17