diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3007fb4..2f3724f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,10 +14,13 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - python-version: ['3.8'] + python-version: ['3.8', '3.12'] toxenv: [ - quality, docs, django32-drf314, django42-drf314 + quality, docs, django42-drf314 ] + exclude: + - python-version: '3.12' + toxenv: 'quality' steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 3cce448..fb60659 100644 --- a/Makefile +++ b/Makefile @@ -37,20 +37,34 @@ dev_requirements: ## Install Dev Requirements test_requirements: ## Install Test Requirements pip install -r requirements/test.txt -upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade -upgrade: ## Update the requirements/*.txt files with the latest packages satisfying requirements/*.in - pip install -qr requirements/pip-tools.txt +piptools: + pip install -q -r requirements/pip-tools.txt + +define COMMON_CONSTRAINTS_TEMP_COMMENT +# This is a temporary solution to override the real common_constraints.txt\n# In edx-lint, until the pyjwt constraint in edx-lint has been removed.\n# See BOM-2721 for more details.\n# Below is the copied and edited version of common_constraints\n +endef + +COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt +.PHONY: $(COMMON_CONSTRAINTS_TXT) +$(COMMON_CONSTRAINTS_TXT): + wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)" + echo "$(COMMON_CONSTRAINTS_TEMP_COMMENT)" | cat - $(@) > temp && mv temp $(@) + +export CUSTOM_COMPILE_COMMAND = make upgrade +upgrade: piptools $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in # Make sure to compile files after any other files they include! pip-compile --upgrade --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in - pip-compile --upgrade --verbose --rebuild -o requirements/pip-tools.txt requirements/pip-tools.in + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/pip-tools.txt requirements/pip-tools.in pip install -qr requirements/pip.txt pip install -qr requirements/pip-tools.txt - pip-compile --upgrade --verbose --rebuild -o requirements/base.txt requirements/base.in - pip-compile --upgrade --verbose --rebuild -o requirements/docs.txt requirements/docs.in - pip-compile --upgrade --verbose --rebuild -o requirements/test.txt requirements/test.in - pip-compile --upgrade --verbose --rebuild -o requirements/dev.txt requirements/dev.in - pip-compile --upgrade --verbose --rebuild -o requirements/tox.txt requirements/tox.in - pip-compile --upgrade --verbose --rebuild -o requirements/ci.txt requirements/ci.in + sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp + mv requirements/common_constraints.tmp requirements/common_constraints.txt + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/base.txt requirements/base.in + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/docs.txt requirements/docs.in + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/test.txt requirements/test.in + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/dev.txt requirements/dev.in + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/tox.txt requirements/tox.in + pip-compile --upgrade --allow-unsafe --verbose --rebuild -o requirements/ci.txt requirements/ci.in # Let tox control the Django and DRF versions for tests sed -i.tmp '/^django==/d' requirements/test.txt sed -i.tmp '/^djangorestframework==/d' requirements/test.txt diff --git a/pylintrc b/pylintrc index cadb490..2853a4d 100644 --- a/pylintrc +++ b/pylintrc @@ -64,7 +64,7 @@ # SERIOUSLY. # # ------------------------------ -# Generated by edx-lint version: 5.2.5 +# Generated by edx-lint version: 5.3.6 # ------------------------------ [MASTER] ignore = @@ -141,7 +141,6 @@ enable = no-self-argument, no-value-for-parameter, non-iterator-returned, - non-parent-method-called, nonexistent-operator, not-a-mapping, not-an-iterable, @@ -161,13 +160,10 @@ enable = return-outside-function, signature-differs, super-init-not-called, - super-method-not-called, syntax-error, - test-inherits-tests, too-few-format-args, too-many-format-args, too-many-function-args, - translation-of-non-string, truncated-format-string, undefined-all-variable, undefined-loop-variable, @@ -213,7 +209,6 @@ enable = consider-using-enumerate, global-at-module-level, global-variable-not-assigned, - literal-used-as-attribute, logging-format-interpolation, logging-not-lazy, multiple-imports, @@ -224,7 +219,6 @@ enable = redundant-unittest-assert, reimported, simplifiable-if-statement, - simplifiable-range, singleton-comparison, superfluous-parens, unidiomatic-typecheck, @@ -233,7 +227,6 @@ enable = unnecessary-semicolon, unneeded-not, useless-else-on-loop, - wrong-assert-type, deprecated-method, deprecated-module, @@ -259,6 +252,7 @@ enable = useless-suppression, disable = bad-indentation, + broad-exception-raised, consider-using-f-string, duplicate-code, file-ignored, @@ -282,9 +276,6 @@ disable = unused-wildcard-import, use-maxsplit-arg, - feature-toggle-needs-doc, - illegal-waffle-usage, - logging-fstring-interpolation, [REPORTS] @@ -380,6 +371,6 @@ ext-import-graph = int-import-graph = [EXCEPTIONS] -overgeneral-exceptions = Exception +overgeneral-exceptions = builtins.Exception -# 54daa2b24c4b5341a45cdb4727fe15d05ef04c5f +# 5f343c05ade94b1f05eeb1763ca543bf867246f6 diff --git a/requirements/base.in b/requirements/base.in index 2da04d9..21b7bc0 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -3,12 +3,8 @@ -c constraints.txt Django -django-model-utils>=2.3.1 - +django-model-utils jsonfield pytz - - -# Don't let edx-platform upgrade DRF past versions that have already been tested here -djangorestframework<3.15.0 +djangorestframework diff --git a/requirements/common_constraints.txt b/requirements/common_constraints.txt new file mode 100644 index 0000000..abe7e1c --- /dev/null +++ b/requirements/common_constraints.txt @@ -0,0 +1,42 @@ +# This is a temporary solution to override the real common_constraints.txt +# In edx-lint, until the pyjwt constraint in edx-lint has been removed. +# See BOM-2721 for more details. +# Below is the copied and edited version of common_constraints + +# This is a temporary solution to override the real common_constraints.txt +# In edx-lint, until the pyjwt constraint in edx-lint has been removed. +# See BOM-2721 for more details. +# Below is the copied and edited version of common_constraints + +# This is a temporary solution to override the real common_constraints.txt +# In edx-lint, until the pyjwt constraint in edx-lint has been removed. +# See BOM-2721 for more details. +# Below is the copied and edited version of common_constraints + +# This is a temporary solution to override the real common_constraints.txt +# In edx-lint, until the pyjwt constraint in edx-lint has been removed. +# See BOM-2721 for more details. +# Below is the copied and edited version of common_constraints + +# A central location for most common version constraints +# (across edx repos) for pip-installation. +# +# Similar to other constraint files this file doesn't install any packages. +# It specifies version constraints that will be applied if a package is needed. +# When pinning something here, please provide an explanation of why it is a good +# idea to pin this package across all edx repos, Ideally, link to other information +# that will help people in the future to remove the pin when possible. +# Writing an issue against the offending project and linking to it here is good. +# +# Note: Changes to this file will automatically be used by other repos, referencing +# this file from Github directly. It does not require packaging in edx-lint. + + +# using LTS django version + + +# 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 + +# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected \ No newline at end of file diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 9972418..e824313 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -9,4 +9,7 @@ # linking to it here is good. # This file contains all common constraints for edx-repos --c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt +# Common constraints for edx repos +-c common_constraints.txt + +backports.zoneinfo;python_version<"3.9" \ No newline at end of file diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 44c48d9..ab115fa 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -29,5 +29,7 @@ zipp==3.17.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -# pip -# setuptools +pip==24.0 + # via pip-tools +setuptools==69.1.1 + # via pip-tools diff --git a/setup.py b/setup.py index 7c81bf5..8855566 100644 --- a/setup.py +++ b/setup.py @@ -74,14 +74,14 @@ def get_version(*file_paths): classifiers=[ 'Development Status :: 3 - Alpha', 'Framework :: Django', - 'Framework :: Django :: 3.2', - 'Framework :: Django :: 4.0', + 'Framework :: Django :: 4.2', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU Affero General Public License v3', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.12', ], packages=find_packages(include=['submissions*'], exclude=['*.test', '*.tests']), install_requires=load_requirements('requirements/base.in'), diff --git a/submissions/__init__.py b/submissions/__init__.py index 75d3609..60e7110 100644 --- a/submissions/__init__.py +++ b/submissions/__init__.py @@ -1,2 +1,2 @@ """ API for creating submissions and scores. """ -__version__ = '3.6.1' +__version__ = '3.7.0' diff --git a/submissions/api.py b/submissions/api.py index 1be2a84..d796273 100644 --- a/submissions/api.py +++ b/submissions/api.py @@ -10,7 +10,7 @@ from uuid import UUID from django.conf import settings -from django.core.cache import cache +from django.core.cache import CacheKeyWarning, cache from django.db import DatabaseError, IntegrityError, transaction # SubmissionError imported so that code importing this api has access @@ -228,7 +228,7 @@ def get_submission(submission_uuid, read_replica=False): cache_key = Submission.get_cache_key(submission_uuid) try: cached_submission_data = cache.get(cache_key) - except Exception: # pylint: disable=broad-except + except CacheKeyWarning: # The cache backend could raise an exception # (for example, memcache keys that contain spaces) logger.exception("Error occurred while retrieving submission from the cache") @@ -293,7 +293,7 @@ def get_submission_and_student(uuid, read_replica=False): cache_key = f"submissions.student_item.{submission['student_item']}" try: cached_student_item = cache.get(cache_key) - except Exception: # pylint: disable=broad-except + except CacheKeyWarning: # The cache backend could raise an exception # (for example, memcache keys that contain spaces) logger.exception("Error occurred while retrieving student item from the cache") diff --git a/tox.ini b/tox.ini index cde9012..d92da35 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,11 @@ [tox] -envlist = py38-django{32,42}-drf{312, drf314}, quality, docs +envlist = py{38,312}-django{42}-drf{drf314}, quality, docs [testenv] setenv = DJANGO_SETTINGS_MODULE = settings deps = -r{toxinidir}/requirements/test.txt - django32: Django>=3.2,<4.0 django42: Django>=4.2,<4.3 drf314: djangorestframework<3.15.0 commands = @@ -23,7 +22,8 @@ commands = make test_quality [testenv:docs] -deps = +deps = + setuptools -r{toxinidir}/requirements/dev.txt commands = python setup.py build_sphinx