Skip to content

Commit

Permalink
Add a note about not implemented exceptions for unknown comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Oct 27, 2023
1 parent 1094d01 commit fcdd4c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/undate/undate.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ def __lt__(self, other: Union["Undate", datetime.date]) -> bool:
raise NotImplementedError(
"Can't compare when one date falls within the other"
)
# NOTE: unsupported comparisons are supposed to return NotImplemented
# However, doing that in this case results in a confusing TypeError!
# TypeError: '<' not supported between instances of 'Undate' and 'Undate'
# How to handle when the comparison is ambiguous / indeterminate?
# we may need a tribool / ternary type (true, false, unknown),
# but not sure what python builtin methods will do with it (unknown = false?)

# for any other case (i.e., self == other), return false
return False
Expand Down

0 comments on commit fcdd4c2

Please sign in to comment.