Challenging to diagnose bad expressions when using numerical comparison operators.
@klarose ci sta già lavorando.
Dal 27/9/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
I have an expression where one side of a comparison operator fails (e.g. undeclared reference). The result is a "no matching overload" error, which isn't very helpful. I expect to see the original failure bubble up to the top of the evaluation.
E.g.
python3 -m celpy -n 'bad < 113.0'
ERROR: <input>:1:1 found no matching overload for 'relation_lt' applied to '(<class 'celpy.evaluation.CELEvalError'>, <class 'celpy.celtypes.DoubleType'>)'
| bad < 113.0
| ^
While the offending part of the expression is still in the output, it's still fairly misleading, and could cause code trying to customize error handling to do the wrong thing.
I took a quick gander where the failure occurs, and it seems to be that the builtin comparison operators don't have an overload for the CELEvalError class. Many of the others do. I'm not sure if this was a miss or on purpose.
Either way, hacking this in seemed to fix the problem:
diff --git a/src/celpy/evaluation.py b/src/celpy/evaluation.py
index 799b05c..8545a02 100644
--- a/src/celpy/evaluation.py
+++ b/src/celpy/evaluation.py
@@ -228,10 +228,22 @@ class CELEvalError(Exception):
def __rpow__(self, other: Any) -> "CELEvalError":
return self
+ def __lt__(self, other: Any) -> "CELEvalError":
+ raise self
+
+ def __le__(self, other: Any) -> "CELEvalError":
+ raise self
+
+ def __gt__(self, other: Any) -> "CELEvalError":
+ raise self
+
+ def __ge__(self, other: Any) -> "CELEvalError":
+ raise self
+
def __eq__(self, other: Any) -> bool:
if isinstance(other, CELEvalError):
return self.args == other.args
- return NotImplemented
+ raise self
def __call__(self, *args: Any) -> "CELEvalError":
return self
I can submit a PR if there's interest.
- Lingua principale
- Python
- Stelle
- 174
- Fork
- 40
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cloud-custodian/cel-python
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cloud-custodian/cel-python#180 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
cloud-custodian/cel-python#194 ·
-
documentation enhancement tracking
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
cloud-custodian/cel-python#182 ·
-
Refresh Features Apertadependencies
cloud-custodian/cel-python#172 · 2 commenti · 1 assegnatario ·
-
enhancement
cloud-custodian/cel-python#169 · 3 commenti · 1 assegnatario ·
Tutte le issue di cloud-custodian/cel-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nwg-piotr/nwg-displays#145 ·