Browse Source

`_evaluate._evaluate` & indirectly `backlight_eval`: raise `ValueError` instead of `Exception` when expression contains prohibited specifier or operator (fixing pylint's `broad-exception-raised` warning)

Fabian Peter Hammerle 1 year ago
parent
commit
808f905cf6
2 changed files with 3 additions and 1 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 1
      acpi_backlight/_evaluate.py

+ 2 - 0
CHANGELOG.md

@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 - made module `acpi_backlight.evaluate` private
+- `acpi_backlight.backlight_eval`: raise `ValueError` instead of `Exception`
+  when expression contains prohibited specifier or operator
 
 TODO document commits before 2022-06-16
 

+ 1 - 1
acpi_backlight/_evaluate.py

@@ -24,7 +24,7 @@ def _evaluate(node, names):
         operand_left = _evaluate(node.left, names=names)
         operand_right = _evaluate(node.right, names=names)
         return _OPERATORS[type(node.op)](operand_left, operand_right)
-    raise Exception(node)
+    raise ValueError(node)
 
 
 def evaluate_expression(expr_str, names):