Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: python3.11 support #102

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 5 additions & 0 deletions calc/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ 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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ichintanjoshi this felt a little late since by now all the other evaluation has happened, what do you think about this alternate proposal where we fix the eval functions upstream instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @feanil sure, that'd work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feanil what should be the next course of actions ?

As we discussed earlier, I agree with your changes and I think it's best to do it in that manner if they are appearing earlier in flow, instead of my approach.

How to proceed with those changes ? Should I change code in this branch ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about you cherry-pick my commits onto your branch since you have more updates here and then we can land your PR and I'll close mine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @feanil

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
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
Expand Down
11 changes: 3 additions & 8 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
UsamaSadiq marked this conversation as resolved.
Show resolved Hide resolved
# by the following command:
#
# make upgrade
Expand Down 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 All @@ -57,12 +57,7 @@ pyproject-api==1.6.1
# tox
requests==2.31.0
# via coveralls
tomli==2.0.1
# via
# -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.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
Expand Down
13 changes: 1 addition & 12 deletions requirements/pip_tools.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
Expand All @@ -8,10 +8,6 @@ build==1.1.1
# via pip-tools
click==8.1.7
# via pip-tools
importlib-metadata==6.11.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# build
packaging==24.0
# via build
pip-tools==7.4.1
Expand All @@ -20,15 +16,8 @@ pyproject-hooks==1.0.0
# via
# build
# pip-tools
tomli==2.0.1
# via
# build
# pip-tools
# pyproject-hooks
wheel==0.43.0
# via pip-tools
zipp==3.18.1
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
15 changes: 3 additions & 12 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -103,18 +103,9 @@ sympy==1.12
# via -r requirements/base.txt
text-unidecode==1.3
# via python-slugify
tomli==2.0.1
# via
# pylint
# pyproject-api
# 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
# astroid
# pylint
virtualenv==20.25.1
# via tox
10 changes: 3 additions & 7 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
Expand All @@ -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 @@ -28,11 +28,7 @@ pluggy==1.4.0
# via tox
pyproject-api==1.6.1
# via tox
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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,quality
envlist = py{38, 311}quality

[testenv]
allowlist_externals =
Expand Down
Loading