Skip to content

Commit ff1a0d6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 358fffe commit ff1a0d6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ardupilot_methodic_configurator/safe_eval.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
BinOperator = Callable[[Number, Number], Number]
2121
UnOperator = Callable[[Number], Number]
2222

23+
2324
def safe_eval(s: str) -> Number:
2425
def checkmath(x: str, *args: Number) -> Number:
2526
if x not in [x for x in dir(math) if "__" not in x]:
2627
msg = f"Unknown func {x}()"
2728
raise SyntaxError(msg)
28-
fun = cast(MathFunc, getattr(math, x))
29+
fun = cast("MathFunc", getattr(math, x))
2930
try:
3031
return fun(*args)
3132
except TypeError as e:
@@ -57,12 +58,12 @@ def _eval(node: ast.AST) -> Number:
5758
return _eval(node.body)
5859
if isinstance(node, ast.Constant):
5960
logger.info("Const")
60-
return cast(Number, node.value)
61+
return cast("Number", node.value)
6162
if isinstance(node, ast.Name):
6263
# Handle math constants like pi, e, etc.
6364
logger.info("MathConst")
6465
if hasattr(math, node.id):
65-
return cast(Number, getattr(math, node.id))
66+
return cast("Number", getattr(math, node.id))
6667
msg = f"Unknown constant: {node.id}"
6768
raise SyntaxError(msg)
6869
if isinstance(node, ast.BinOp):

0 commit comments

Comments
 (0)