diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09361f4..f323f9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ ubuntu-20.04 ] - python-version: [ 3.8 ] + python-version: [ 3.8, 3.11 ] toxenv: [ py38, quality ] steps: diff --git a/calc/__init__.py b/calc/__init__.py index 434fcd9..1a9b5fa 100644 --- a/calc/__init__.py +++ b/calc/__init__.py @@ -6,4 +6,4 @@ from .calc import * -__version__ = '3.0.1' +__version__ = '3.1.0' diff --git a/calc/calc.py b/calc/calc.py index bee9310..1fea477 100644 --- a/calc/calc.py +++ b/calc/calc.py @@ -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): @@ -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 == '+': @@ -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 == '*': diff --git a/requirements/base.txt b/requirements/base.txt index e42ef85..c3accbc 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,7 +4,7 @@ # # make upgrade # -lxml==5.1.0 +lxml==5.2.1 # via -r requirements/base.in markupsafe==2.1.5 # via -r requirements/base.in diff --git a/requirements/ci.txt b/requirements/ci.txt index c45838a..53fbcda 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -30,7 +30,7 @@ distlib==0.3.8 # virtualenv docopt==0.6.2 # via coveralls -filelock==3.13.1 +filelock==3.13.3 # via # -r requirements/tox.txt # tox @@ -62,7 +62,7 @@ tomli==2.0.1 # -r requirements/tox.txt # pyproject-api # tox -tox==4.14.1 +tox==4.14.2 # via -r requirements/tox.txt urllib3==2.2.1 # via requests diff --git a/requirements/pip_tools.txt b/requirements/pip_tools.txt index 152da44..e64299a 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -4,7 +4,7 @@ # # make upgrade # -build==1.1.1 +build==1.2.1 # via pip-tools click==8.1.7 # via pip-tools diff --git a/requirements/test.txt b/requirements/test.txt index f9dda99..597918f 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -31,7 +31,7 @@ distlib==0.3.8 # via virtualenv edx-lint==5.3.6 # via -r requirements/test.in -filelock==3.13.1 +filelock==3.13.3 # via # tox # virtualenv @@ -39,7 +39,7 @@ isort==5.13.2 # via pylint jinja2==3.1.3 # via code-annotations -lxml==5.1.0 +lxml==5.2.1 # via -r requirements/base.txt markupsafe==2.1.5 # via @@ -110,7 +110,7 @@ tomli==2.0.1 # tox tomlkit==0.12.4 # via pylint -tox==4.14.1 +tox==4.14.2 # via -r requirements/test.in typing-extensions==4.10.0 # via diff --git a/requirements/tox.txt b/requirements/tox.txt index daf54ce..cc5293d 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -12,7 +12,7 @@ colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -filelock==3.13.1 +filelock==3.13.3 # via # tox # virtualenv @@ -32,7 +32,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.14.1 +tox==4.14.2 # via -r requirements/tox.in virtualenv==20.25.1 # via tox diff --git a/setup.py b/setup.py index c6e7030..0ba094d 100644 --- a/setup.py +++ b/setup.py @@ -78,5 +78,6 @@ def get_version(*file_paths): 'Natural Language :: English', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.11', ], ) diff --git a/tests/test_calc.py b/tests/test_calc.py index bb980b4..b43d423 100644 --- a/tests/test_calc.py +++ b/tests/test_calc.py @@ -348,9 +348,13 @@ def test_other_functions(self): self.assert_function_values('factorial', fact_inputs, fact_values) self.assertRaises(ValueError, calc.evaluator, {}, {}, "fact(-1)") - self.assertRaises(ValueError, calc.evaluator, {}, {}, "fact(0.5)") + # There are 2 errors below because py3.8 raises ValueError and 3.11 raises TypeError + # Value error to be removed when we remove py3.8 support + self.assertRaises((TypeError, ValueError), calc.evaluator, {}, {}, "fact(0.5)") self.assertRaises(ValueError, calc.evaluator, {}, {}, "factorial(-1)") - self.assertRaises(ValueError, calc.evaluator, {}, {}, "factorial(0.5)") + # There are 2 errors below because py3.8 raises ValueError and 3.11 raises TypeError + # Value error to be removed when we remove py3.8 support + self.assertRaises((TypeError, ValueError), calc.evaluator, {}, {}, "factorial(0.5)") def test_constants(self): """ diff --git a/tox.ini b/tox.ini index 4e25818..3d77849 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,11 @@ [tox] -envlist = py38,quality +envlist = py{38,311},quality [testenv] allowlist_externals = touch deps = + setuptools -r requirements/test.txt commands = coverage run setup.py test @@ -12,6 +13,7 @@ commands = [testenv:quality] deps = + setuptools -r requirements/test.txt commands = pycodestyle calc symmath tests