Skip to content

Commit

Permalink
build: python 3.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ichintanjoshi committed Apr 8, 2024
1 parent 4c5a13e commit 3347c02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 7 additions & 8 deletions calc/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def eval_number(parse_result):
e.g. [ '7.13', 'e', '3' ] -> 7130
Calls super_float above.
"""
return super_float("".join(parse_result))
for item in parse_result:
if "." in item or "e" in item or "E" in item:
return super_float("".join(parse_result))

return int("".join(parse_result))


def eval_atom(parse_result):
Expand Down Expand Up @@ -185,7 +189,7 @@ def eval_sum(parse_result):
Allow a leading + or -.
"""
total = 0.0
total = 0
current_op = operator.add
for token in parse_result:
if token == '+':
Expand All @@ -203,7 +207,7 @@ def eval_product(parse_result):
[ 1, '*', 2, '/', 3 ] -> 0.66
"""
prod = 1.0
prod = 1
current_op = operator.mul
for token in parse_result:
if token == '*':
Expand Down Expand Up @@ -265,11 +269,6 @@ def eval_variable(x):
return all_variables[casify(x[0])]

def eval_function(x):
# This condition here is only for factorial function
if isinstance(x[1], numbers.Real):
if math.ceil(x[1]) == x[1]:
return all_functions[casify(x[0])](int(x[1]))

return all_functions[casify(x[0])](x[1])

evaluate_actions = {
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[tox]
envlist = py{38, 311}quality
envlist = py{38,311},quality

[testenv]
allowlist_externals =
touch
deps =
setuptools
-r requirements/test.txt
commands =
coverage run setup.py test
coverage report

[testenv:quality]
deps =
setuptools
-r requirements/test.txt
commands =
pycodestyle calc symmath tests
Expand Down

0 comments on commit 3347c02

Please sign in to comment.