Skip to content

Commit

Permalink
Override BitLengthSet.__bool__
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Apr 6, 2021
1 parent a62ffb0 commit f0b8fca
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pydsdl/_bit_length_set/_bit_length_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,15 @@ def __eq__(self, other: typing.Any) -> bool:

# ======================================== AUXILIARY METHODS ========================================

def __bool__(self) -> bool:
"""
This method is overridden to avoid accidental invocation of :meth:`__len__` in boolean expressions
because it triggers numerical expansion.
:return: Always True.
"""
return True

def __str__(self) -> str:
return str(self._op)

Expand Down

0 comments on commit f0b8fca

Please sign in to comment.