From 5ae386ef99c85ba48f834f69eb92cc1ece431d83 Mon Sep 17 00:00:00 2001 From: edX requirements bot Date: Fri, 23 Feb 2024 07:37:39 -0500 Subject: [PATCH 1/4] feat: add python 3.12 support --- .github/workflows/ci.yml | 10 +++++----- tox.ini | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09361f4..aaca709 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: Python CI on: push: branches: - - master + - master pull_request: branches: - - '**' + - '**' jobs: run_tests: @@ -14,9 +14,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-20.04 ] - python-version: [ 3.8 ] - toxenv: [ py38, quality ] + os: [ubuntu-20.04] + python-version: [3.8, '3.8', '3.12'] + toxenv: [py38, quality, django42] steps: - uses: actions/checkout@v2 diff --git a/tox.ini b/tox.ini index 4e25818..f1c5cf3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,19 @@ [tox] -envlist = py38,quality +envlist = py{38, 312}quality [testenv] -allowlist_externals = - touch -deps = - -r requirements/test.txt -commands = - coverage run setup.py test - coverage report +allowlist_externals = + touch +deps = + -r requirements/test.txt +commands = + coverage run setup.py test + coverage report [testenv:quality] -deps = - -r requirements/test.txt -commands = - pycodestyle calc symmath tests - pylint calc symmath tests +deps = + -r requirements/test.txt +commands = + pycodestyle calc symmath tests + pylint calc symmath tests + From 290143fbb8c083b2dd87b21ffd9214cfb1447fa0 Mon Sep 17 00:00:00 2001 From: Chintan Joshi Date: Sun, 24 Mar 2024 15:36:48 +0300 Subject: [PATCH 2/4] build: add python 3.11 support --- .github/workflows/ci.yml | 2 +- requirements/base.txt | 18 ++--- requirements/ci.txt | 59 ++++++++-------- requirements/common_constraints.txt | 13 +++- requirements/pip.txt | 14 ++-- requirements/pip_tools.txt | 22 +++--- requirements/test.txt | 105 +++++++++++++--------------- requirements/tox.txt | 38 +++++----- setup.py | 1 + tox.ini | 2 +- 10 files changed, 134 insertions(+), 140 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaca709..78d23c7 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, '3.8', '3.12'] + python-version: ['3.8', '3.11'] toxenv: [py38, quality, django42] steps: diff --git a/requirements/base.txt b/requirements/base.txt index 677cc0e..7e701cb 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,22 +1,22 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # make upgrade # -lxml==4.9.1 +lxml==5.1.0 # via -r requirements/base.in -markupsafe==2.1.1 +markupsafe==2.1.5 # via -r requirements/base.in -mpmath==1.2.1 +mpmath==1.3.0 # via sympy -numpy==1.23.1 +numpy==1.26.4 # via # -r requirements/base.in # scipy -pyparsing==3.0.9 +pyparsing==3.1.2 # via -r requirements/base.in -scipy==1.8.1 +scipy==1.12.0 # via -r requirements/base.in -sympy==1.10.1 +sympy==1.12 # via -r requirements/base.in diff --git a/requirements/ci.txt b/requirements/ci.txt index 555ff58..c32c5e4 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,66 +1,67 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # make upgrade # -certifi==2022.6.15 +cachetools==5.3.3 + # via + # -r requirements/tox.txt + # tox +certifi==2024.2.2 # via requests -charset-normalizer==2.1.0 +chardet==5.2.0 + # via + # -r requirements/tox.txt + # tox +charset-normalizer==3.3.2 # via requests -coverage==6.4.2 +colorama==0.4.6 + # via + # -r requirements/tox.txt + # tox +coverage==6.5.0 # via coveralls coveralls==3.3.1 # via -r requirements/ci.in -distlib==0.3.5 +distlib==0.3.8 # via # -r requirements/tox.txt # virtualenv docopt==0.6.2 # via coveralls -filelock==3.7.1 +filelock==3.13.1 # via # -r requirements/tox.txt # tox # virtualenv -idna==3.3 +idna==3.6 # via requests -packaging==21.3 +packaging==24.0 # via # -r requirements/tox.txt + # pyproject-api # tox -platformdirs==2.5.2 +platformdirs==4.2.0 # via # -r requirements/tox.txt + # tox # virtualenv -pluggy==1.0.0 +pluggy==1.4.0 # via # -r requirements/tox.txt # tox -py==1.11.0 +pyproject-api==1.6.1 # via # -r requirements/tox.txt # tox -pyparsing==3.0.9 - # via - # -r requirements/tox.txt - # packaging -requests==2.28.1 +requests==2.31.0 # via coveralls -six==1.16.0 - # via - # -r requirements/tox.txt - # tox - # virtualenv -toml==0.10.2 - # via - # -r requirements/tox.txt - # tox -tox==3.25.1 +tox==4.14.2 # via -r requirements/tox.txt -urllib3==1.26.10 +urllib3==2.2.1 # via requests -virtualenv==20.15.1 +virtualenv==20.25.1 # via # -r requirements/tox.txt # tox diff --git a/requirements/common_constraints.txt b/requirements/common_constraints.txt index cca3ccd..e3bf8ea 100644 --- a/requirements/common_constraints.txt +++ b/requirements/common_constraints.txt @@ -13,13 +13,20 @@ # using LTS django version -Django<4.0 +Django<5.0 # elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process. # elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html elasticsearch<7.14.0 -setuptools<60 - # django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected django-simple-history==3.0.0 + +# opentelemetry requires version 6.x at the moment: +# https://github.com/open-telemetry/opentelemetry-python/issues/3570 +# Normally this could be added as a constraint in edx-django-utils, where we're +# adding the opentelemetry dependency. However, when we compile pip-tools.txt, +# that uses version 7.x, and then there's no undoing that when compiling base.txt. +# So we need to pin it globally, for now. +# Ticket for unpinning: https://github.com/openedx/edx-lint/issues/407 +importlib-metadata<7 diff --git a/requirements/pip.txt b/requirements/pip.txt index 0495eb8..218ba66 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -1,16 +1,14 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # make upgrade # -wheel==0.37.1 +wheel==0.43.0 # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==22.2 +pip==24.0 + # via -r requirements/pip.in +setuptools==69.2.0 # via -r requirements/pip.in -setuptools==59.8.0 - # via - # -c requirements/common_constraints.txt - # -r requirements/pip.in diff --git a/requirements/pip_tools.txt b/requirements/pip_tools.txt index 32b8de6..14de3e4 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -1,26 +1,22 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # make upgrade # -build==0.8.0 +build==1.1.1 # via pip-tools -click==8.1.3 +click==8.1.7 # via pip-tools -packaging==21.3 +packaging==24.0 # via build -pep517==0.12.0 - # via build -pip-tools==6.8.0 +pip-tools==7.4.1 # via -r requirements/pip_tools.in -pyparsing==3.0.9 - # via packaging -tomli==2.0.1 +pyproject-hooks==1.0.0 # via # build - # pep517 -wheel==0.37.1 + # pip-tools +wheel==0.43.0 # via pip-tools # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.txt b/requirements/test.txt index 95b7406..cb7a455 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,71 +1,76 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # make upgrade # -astroid==2.11.7 +astroid==3.1.0 # via # pylint # pylint-celery -click==8.1.3 +cachetools==5.3.3 + # via tox +chardet==5.2.0 + # via tox +click==8.1.7 # via # click-log # code-annotations # edx-lint click-log==0.4.0 # via edx-lint -code-annotations==1.3.0 +code-annotations==1.7.0 # via edx-lint -coverage==6.4.2 +colorama==0.4.6 + # via tox +coverage==7.4.4 # via -r requirements/test.in -dill==0.3.5.1 +dill==0.3.8 # via pylint -distlib==0.3.5 +distlib==0.3.8 # via virtualenv -edx-lint==5.2.4 +edx-lint==5.3.6 # via -r requirements/test.in -filelock==3.7.1 +filelock==3.13.1 # via # tox # virtualenv -isort==5.10.1 +isort==5.13.2 # via pylint -jinja2==3.1.2 +jinja2==3.1.3 # via code-annotations -lazy-object-proxy==1.7.1 - # via astroid -lxml==4.9.1 +lxml==5.1.0 # via -r requirements/base.txt -markupsafe==2.1.1 +markupsafe==2.1.5 # via # -r requirements/base.txt # jinja2 mccabe==0.7.0 # via pylint -mpmath==1.2.1 +mpmath==1.3.0 # via # -r requirements/base.txt # sympy -numpy==1.23.1 +numpy==1.26.4 # via # -r requirements/base.txt # scipy -packaging==21.3 - # via tox -pbr==5.9.0 +packaging==24.0 + # via + # pyproject-api + # tox +pbr==6.0.0 # via stevedore -platformdirs==2.5.2 +platformdirs==4.2.0 # via # pylint + # tox # virtualenv -pluggy==1.0.0 - # via tox -py==1.11.0 +pluggy==1.4.0 # via tox -pycodestyle==2.8.0 +pycodestyle==2.11.1 # via -r requirements/test.in -pylint==2.14.5 +pylint==3.1.0 # via # -r requirements/test.in # edx-lint @@ -74,49 +79,33 @@ pylint==2.14.5 # pylint-plugin-utils pylint-celery==0.3 # via edx-lint -pylint-django==2.5.3 +pylint-django==2.5.5 # via edx-lint -pylint-plugin-utils==0.7 +pylint-plugin-utils==0.8.2 # via # pylint-celery # pylint-django -pyparsing==3.0.9 - # via - # -r requirements/base.txt - # packaging -python-slugify==6.1.2 +pyparsing==3.1.2 + # via -r requirements/base.txt +pyproject-api==1.6.1 + # via tox +python-slugify==8.0.4 # via code-annotations -pyyaml==6.0 +pyyaml==6.0.1 # via code-annotations -scipy==1.8.1 +scipy==1.12.0 # via -r requirements/base.txt six==1.16.0 - # via - # edx-lint - # tox - # virtualenv -stevedore==4.0.0 + # via edx-lint +stevedore==5.2.0 # via code-annotations -sympy==1.10.1 +sympy==1.12 # via -r requirements/base.txt text-unidecode==1.3 # via python-slugify -toml==0.10.2 - # via tox -tomli==2.0.1 - # via pylint -tomlkit==0.11.1 +tomlkit==0.12.4 # via pylint -tox==3.25.1 +tox==4.14.2 # via -r requirements/test.in -typing-extensions==4.3.0 - # via - # astroid - # pylint -virtualenv==20.15.1 +virtualenv==20.25.1 # via tox -wrapt==1.14.1 - # via astroid - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/requirements/tox.txt b/requirements/tox.txt index 66512a3..8ccf9db 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -1,32 +1,34 @@ # -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # make upgrade # -distlib==0.3.5 +cachetools==5.3.3 + # via tox +chardet==5.2.0 + # via tox +colorama==0.4.6 + # via tox +distlib==0.3.8 # via virtualenv -filelock==3.7.1 +filelock==3.13.1 # via # tox # virtualenv -packaging==21.3 - # via tox -platformdirs==2.5.2 - # via virtualenv -pluggy==1.0.0 - # via tox -py==1.11.0 - # via tox -pyparsing==3.0.9 - # via packaging -six==1.16.0 +packaging==24.0 + # via + # pyproject-api + # tox +platformdirs==4.2.0 # via # tox # virtualenv -toml==0.10.2 +pluggy==1.4.0 + # via tox +pyproject-api==1.6.1 # via tox -tox==3.25.1 +tox==4.14.2 # via -r requirements/tox.in -virtualenv==20.15.1 +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/tox.ini b/tox.ini index f1c5cf3..5684354 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{38, 312}quality +envlist = py{38, 311}quality [testenv] allowlist_externals = From 635a846a33dffa1f646d2b6982b7de4b15d09129 Mon Sep 17 00:00:00 2001 From: Chintan Joshi Date: Sun, 24 Mar 2024 15:37:30 +0300 Subject: [PATCH 3/4] feat: add a check for integers in factorials and typeerror in floats --- calc/calc.py | 7 +++++++ tests/test_calc.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/calc/calc.py b/calc/calc.py index bee9310..5c252b3 100644 --- a/calc/calc.py +++ b/calc/calc.py @@ -126,6 +126,7 @@ def eval_number(parse_result): e.g. [ '7.13', 'e', '3' ] -> 7130 Calls super_float above. + """ return super_float("".join(parse_result)) @@ -203,6 +204,7 @@ def eval_product(parse_result): [ 1, '*', 2, '/', 3 ] -> 0.66 """ + prod = 1.0 current_op = operator.mul for token in parse_result: @@ -265,6 +267,11 @@ def eval_variable(x): return all_variables[casify(x[0])] def eval_function(x): + # This logic heare 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 = { diff --git a/tests/test_calc.py b/tests/test_calc.py index bb980b4..47f3202 100644 --- a/tests/test_calc.py +++ b/tests/test_calc.py @@ -348,9 +348,9 @@ 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)") + self.assertRaises(TypeError, calc.evaluator, {}, {}, "fact(0.5)") self.assertRaises(ValueError, calc.evaluator, {}, {}, "factorial(-1)") - self.assertRaises(ValueError, calc.evaluator, {}, {}, "factorial(0.5)") + self.assertRaises(TypeError, calc.evaluator, {}, {}, "factorial(0.5)") def test_constants(self): """ From 55dcdc1d7f5301b7cdcadee311f14ba013ab7c7e Mon Sep 17 00:00:00 2001 From: Chintan Joshi Date: Sun, 24 Mar 2024 15:41:30 +0300 Subject: [PATCH 4/4] chore: remove whitespaces and correct typos --- calc/calc.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/calc/calc.py b/calc/calc.py index 5c252b3..92fdeab 100644 --- a/calc/calc.py +++ b/calc/calc.py @@ -126,7 +126,6 @@ def eval_number(parse_result): e.g. [ '7.13', 'e', '3' ] -> 7130 Calls super_float above. - """ return super_float("".join(parse_result)) @@ -204,7 +203,6 @@ def eval_product(parse_result): [ 1, '*', 2, '/', 3 ] -> 0.66 """ - prod = 1.0 current_op = operator.mul for token in parse_result: @@ -267,7 +265,7 @@ def eval_variable(x): return all_variables[casify(x[0])] def eval_function(x): - # This logic heare is only for factorial function + # This logic 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]))