Skip to content

Commit f029e34

Browse files
authored
Merge pull request Pyomo#3746 from eminyouskn/deferred-import-indicator-bool
Fix boolean conversion in DeferredImportIndicator class
2 parents e8ed5dd + e27bd21 commit f029e34

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pyomo/common/dependencies.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ def __init__(
346346

347347
def __bool__(self):
348348
self.resolve()
349-
return self._available
349+
# resolve() guarantees that _available has been resolved to a bool
350+
assert self._available.__class__ is bool
351+
# The following cast is to keep static code analysis linters happy
352+
return bool(self._available)
350353

351354
def resolve(self):
352355
# Only attempt the import once, then cache some form of result

0 commit comments

Comments
 (0)