Skip to content

Commit

Permalink
Merge pull request #102 from ichintanjoshi/add-python3.11-supports
Browse files Browse the repository at this point in the history
feat: python3.11 support
  • Loading branch information
Feanil Patel authored Apr 8, 2024
2 parents 3eba2eb + 3347c02 commit 95d2e58
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion calc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

from .calc import *

__version__ = '3.0.1'
__version__ = '3.1.0'
10 changes: 7 additions & 3 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
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
build==1.1.1
build==1.2.1
# via pip-tools
click==8.1.7
# via pip-tools
Expand Down
6 changes: 3 additions & 3 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ 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
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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
)
8 changes: 6 additions & 2 deletions tests/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
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 = py38,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 95d2e58

Please sign in to comment.