From 4133ce8d81b5a9b88c95cb83691ef79e1bf94231 Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Fri, 22 Nov 2019 17:31:20 +0500 Subject: [PATCH] BOM-1044 Django22 support -Updated travis file -updated requirements -updated tox test envs -removed authors -updated tests -removed unused dependency django-nose -bump version --- .travis.yml | 15 +- AUTHORS | 7 - pylintrc | 458 ++++++++++++++++++++++++++++++- pylintrc_tweaks | 9 + requirements/base.in | 3 +- requirements/base.txt | 28 +- requirements/dev.txt | 83 +++--- requirements/pip-tools.txt | 4 +- requirements/test.in | 4 +- requirements/test.txt | 66 +++-- requirements/travis.txt | 17 +- setup.py | 2 +- tests/unit/test_publish_event.py | 4 +- tox.ini | 9 +- xblockutils/base_test.py | 2 +- xblockutils/publish_event.py | 2 +- xblockutils/resources.py | 6 +- xblockutils/studio_editable.py | 23 +- xblockutils/templatetags/i18n.py | 2 +- 19 files changed, 609 insertions(+), 135 deletions(-) delete mode 100644 AUTHORS create mode 100644 pylintrc_tweaks diff --git a/.travis.yml b/.travis.yml index 9bbcb9f..5e4765d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,24 +2,23 @@ language: python dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069) python: - 2.7 - - 3.6 - - 3.7 + - 3.5 env: - TOXENV=django111 - TOXENV=django20 - TOXENV=django21 - - TOXENV=quality + - TOXENV=django22 matrix: + include: + - python: 3.5 + env: TOXENV=quality exclude: - python: 2.7 env: TOXENV=django20 - python: 2.7 env: TOXENV=django21 - - python: 3.6 - env: TOXENV=quality - allow_failures: - - env: TOXENV=django20 - - env: TOXENV=django21 + - python: 2.7 + env: TOXENV=django22 services: - xvfb diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 22c5b59..0000000 --- a/AUTHORS +++ /dev/null @@ -1,7 +0,0 @@ -Braden MacDonald -David Gabor Bodor -Jonathan Piacenti -Matjaz Gregoric -Ned Batchelder -Xavier Antoviaque -Eugeny Kolpakov diff --git a/pylintrc b/pylintrc index dba3cc8..621502c 100644 --- a/pylintrc +++ b/pylintrc @@ -1,27 +1,457 @@ -[REPORTS] -reports=no - -[FORMAT] -max-line-length=120 +# *************************** +# ** DO NOT EDIT THIS FILE ** +# *************************** +# +# This file was generated by edx-lint: http://github.com/edx/edx-lint +# +# If you want to change this file, you have two choices, depending on whether +# you want to make a local change that applies only to this repo, or whether +# you want to make a central change that applies to all repos using edx-lint. +# +# LOCAL CHANGE: +# +# 1. Edit the local pylintrc_tweaks file to add changes just to this +# repo's file. +# +# 2. Run: +# +# $ edx_lint write pylintrc +# +# 3. This will modify the local file. Submit a pull request to get it +# checked in so that others will benefit. +# +# +# CENTRAL CHANGE: +# +# 1. Edit the pylintrc file in the edx-lint repo at +# https://github.com/edx/edx-lint/blob/master/edx_lint/files/pylintrc +# +# 2. install the updated version of edx-lint (in edx-lint): +# +# $ pip install . +# +# 3. Run (in edx-lint): +# +# # uses pylintrc_tweaks from edx-lint for linting in edx-lint +# # NOTE: Use Python 3.x, which no longer includes comments in the output file +# $ edx_lint write pylintrc +# +# 4. Make a new version of edx_lint, submit and review a pull request with the +# pylintrc update, and after merging, update the edx-lint version by +# creating a new tag in the repo (uses pbr). +# +# 5. In your local repo, install the newer version of edx-lint. +# +# 6. Run: +# +# # uses local pylintrc_tweaks +# $ edx_lint write pylintrc +# +# 7. This will modify the local file. Submit a pull request to get it +# checked in so that others will benefit. +# +# +# +# +# +# STAY AWAY FROM THIS FILE! +# +# +# +# +# +# SERIOUSLY. +# +# ------------------------------ +[MASTER] +ignore = .tox,migrations,tests,.pycharm_helpers +persistent = yes +load-plugins = edx_lint.pylint,pylint_django,pylint_celery [MESSAGES CONTROL] -disable= - abstract-class-not-used, +enable = + blacklisted-name, + line-too-long, + + syntax-error, + init-is-generator, + return-in-init, + function-redefined, + not-in-loop, + return-outside-function, + yield-outside-function, + return-arg-in-generator, + nonexistent-operator, + duplicate-argument-name, + abstract-class-instantiated, + bad-reversed-sequence, + continue-in-finally, + method-hidden, + access-member-before-definition, + no-method-argument, + no-self-argument, + invalid-slots-object, + assigning-non-slot, + invalid-slots, + inherit-non-class, + inconsistent-mro, + duplicate-bases, + non-iterator-returned, + unexpected-special-method-signature, + invalid-length-returned, + import-error, + used-before-assignment, + undefined-variable, + undefined-all-variable, + invalid-all-object, + no-name-in-module, + unbalance-tuple-unpacking, + unpacking-non-sequence, + bad-except-order, + raising-bad-type, + misplaced-bare-raise, + raising-non-exception, + nonimplemented-raised, + catching-non-exception, + slots-on-old-class, + super-on-old-class, + bad-super-call, + missing-super-argument, + no-member, + not-callable, + assignment-from-no-return, + no-value-for-parameter, + too-many-function-args, + unexpected-keyword-arg, + redundant-keyword-arg, + invalid-sequence-index, + invalid-slice-index, + assignment-from-none, + not-context-manager, + invalid-unary-operand-type, + unsupported-binary-operation, + repeated-keyword, + not-an-iterable, + not-a-mapping, + unsupported-membership-test, + unsubscriptable-object, + logging-unsupported-format, + logging-too-many-args, + logging-too-few-args, + bad-format-character, + truncated-format-string, + mixed-fomat-string, + format-needs-mapping, + missing-format-string-key, + too-many-format-args, + too-few-format-args, + bad-str-strip-call, + model-unicode-not-callable, + super-method-not-called, + non-parent-method-called, + test-inherits-tests, + translation-of-non-string, + redefined-variable-type, + cyclical-import, + unreachable, + dangerous-default-value, + pointless-statement, + pointless-string-statement, + expression-not-assigned, + duplicate-key, + confusing-with-statement, + using-constant-test, + lost-exception, + assert-on-tuple, + attribute-defined-outside-init, + bad-staticmethod-argument, + arguments-differ, + signature-differs, + abstract-method, + super-init-not-called, + relative-import, + import-self, + misplaced-future, + invalid-encoded-data, + global-variable-undefined, + redefined-outer-name, + redefined-builtin, + redefined-in-handler, + undefined-loop-variable, + cell-var-from-loop, + duplicate-except, + nonstandard-exception, + binary-op-exception, + property-on-old-class, + bad-format-string-key, + unused-format-string-key, + bad-format-string, + missing-format-argument-key, + unused-format-string-argument, + format-combined-specification, + missing-format-attribute, + invalid-format-index, + anomalous-backslash-in-string, + anomalous-unicode-escape-in-string, + bad-open-mode, + boolean-datetime, + + fatal, + astroid-error, + parse-error, + method-check-failed, + django-not-available, + raw-checker-failed, + django-not-available-placeholder, + + empty-docstring, + invalid-characters-in-docstring, + missing-docstring, + wrong-spelling-in-comment, + wrong-spelling-in-docstring, + + unused-import, + unused-variable, + unused-argument, + + exec-used, + eval-used, + + bad-classmethod-argument, + bad-mcs-classmethod-argument, + bad-mcs-method-argument, + bad-whitespace, + consider-iterating-dictionary, + consider-using-enumerate, + literal-used-as-attribute, + multiple-imports, + multiple-statements, + old-style-class, + simplifiable-range, + singleton-comparison, + superfluous-parens, + unidiomatic-typecheck, + unneeded-not, + wrong-assert-type, + simplifiable-if-statement, + no-classmethod-decorator, + no-staticmethod-decorator, + unnecessary-pass, + unnecessary-lambda, + useless-else-on-loop, + unnecessary-semicolon, + reimported, + global-variable-not-assigned, + global-at-module-level, + bare-except, broad-except, - fixme, + logging-not-lazy, + redundant-unittest-assert, + model-missing-unicode, + model-has-unicode, + model-no-explicit-unicode, + protected-access, + + deprecated-module, + deprecated-method, + + too-many-nested-blocks, + too-many-statements, + too-many-boolean-expressions, + + wrong-import-order, + wrong-import-position, + wildcard-import, + + missing-final-newline, + mixed-line-endings, + trailing-newlines, + trailing-whitespace, + unexpected-line-ending-format, + mixed-indentation, + + bad-option-value, + unrecognized-inline-option, + useless-suppression, + bad-inline-option, + deprecated-pragma, +disable = + bad-continuation, invalid-name, + misplaced-comparison-constant, + file-ignored, + bad-indentation, + lowercase-l-suffix, + unused-wildcard-import, + global-statement, + no-else-return, + + apply-builtin, + backtick, + basestring-builtin, + buffer-builtin, + cmp-builtin, + cmp-method, + coerce-builtin, + coerce-method, + delslice-method, + dict-iter-method, + dict-view-method, + duplicate-code, + execfile-builtin, + feature-toggle-needs-doc, + file-builtin, + filter-builtin-not-iterating, + fixme, + getslice-method, + hex-method, + illegal-waffle-usage, + import-star-module-level, + indexing-exception, + input-builtin, + intern-builtin, locally-disabled, - maybe-no-member, - protected-access, - star-args, + locally-enabled, + logging-format-interpolation, + long-builtin, + long-suffix, + map-builtin-not-iterating, + metaclass-assignment, + next-method-called, + no-absolute-import, + no-init, + no-self-use, + nonzero-method, + oct-method, + old-division, + old-ne-operator, + old-octal-literal, + old-raise-syntax, + parameter-unpacking, + print-statement, + raising-string, + range-builtin-not-iterating, + raw_input-builtin, + reduce-builtin, + reload-builtin, + round-builtin, + setslice-method, + standarderror-builtin, + suppressed-message, too-few-public-methods, too-many-ancestors, too-many-arguments, too-many-branches, + too-many-instance-attributes, + too-many-lines, too-many-locals, too-many-public-methods, - too-many-statements, - unused-argument + too-many-return-statements, + ungrouped-imports, + unichr-builtin, + unicode-builtin, + unpacking-in-except, + using-cmp-argument, + xrange-builtin, + zip-builtin-not-iterating, + useless-object-inheritance, + +[REPORTS] +output-format = text +files-output = no +reports = no +evaluation = 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +[BASIC] +bad-functions = map,filter,apply,input +module-rgx = (([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ +const-rgx = (([A-Z_][A-Z0-9_]*)|(__.*__)|log|urlpatterns)$ +class-rgx = [A-Z_][a-zA-Z0-9]+$ +function-rgx = ([a-z_][a-z0-9_]{2,40}|test_[a-z0-9_]+)$ +method-rgx = ([a-z_][a-z0-9_]{2,40}|setUp|set[Uu]pClass|tearDown|tear[Dd]ownClass|assert[A-Z]\w*|maxDiff|test_[a-z0-9_]+)$ +attr-rgx = [a-z_][a-z0-9_]{2,30}$ +argument-rgx = [a-z_][a-z0-9_]{2,30}$ +variable-rgx = [a-z_][a-z0-9_]{2,30}$ +class-attribute-rgx = ([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ +inlinevar-rgx = [A-Za-z_][A-Za-z0-9_]*$ +good-names = f,i,j,k,db,ex,Run,_,__ +bad-names = foo,bar,baz,toto,tutu,tata +no-docstring-rgx = __.*__$|test_.+|setUp$|setUpClass$|tearDown$|tearDownClass$|Meta$ +docstring-min-length = 5 + +[FORMAT] +max-line-length = 120 +ignore-long-lines = ^\s*(# )?((?)|(\.\. \w+: .*))$ +single-line-if-stmt = no +no-space-check = trailing-comma,dict-separator +max-module-lines = 1000 +indent-string = ' ' + +[MISCELLANEOUS] +notes = FIXME,XXX,TODO [SIMILARITIES] -min-similarity-lines=8 +min-similarity-lines = 4 +ignore-comments = yes +ignore-docstrings = yes +ignore-imports = no + +[TYPECHECK] +ignore-mixin-members = yes +ignored-classes = SQLObject +unsafe-load-any-extension = yes +generated-members = + REQUEST, + acl_users, + aq_parent, + objects, + DoesNotExist, + can_read, + can_write, + get_url, + size, + content, + status_code, + create, + build, + fields, + tag, + org, + course, + category, + name, + revision, + _meta, + +[VARIABLES] +init-import = no +dummy-variables-rgx = _|dummy|unused|.*_unused +additional-builtins = + +[CLASSES] +defining-attr-methods = __init__,__new__,setUp +valid-classmethod-first-arg = cls +valid-metaclass-classmethod-first-arg = mcs + +[DESIGN] +max-args = 5 +ignored-argument-names = _.* +max-locals = 15 +max-returns = 6 +max-branches = 12 +max-statements = 50 +max-parents = 7 +max-attributes = 7 +min-public-methods = 2 +max-public-methods = 20 + +[IMPORTS] +deprecated-modules = regsub,TERMIOS,Bastion,rexec +import-graph = +ext-import-graph = +int-import-graph = + +[EXCEPTIONS] +overgeneral-exceptions = Exception + +# c22b10ad981357b4c544549658a94092255a50d4 diff --git a/pylintrc_tweaks b/pylintrc_tweaks new file mode 100644 index 0000000..7d45ea6 --- /dev/null +++ b/pylintrc_tweaks @@ -0,0 +1,9 @@ +# pylintrc tweaks for use with edx_lint. +[MASTER] +ignore = .tox,migrations,tests,.pycharm_helpers +load-plugins = edx_lint.pylint,pylint_django,pylint_celery + +[MESSAGES CONTROL] +# Disable unicode-format-string until we can agree to turn it on. +disable+ = + useless-object-inheritance, diff --git a/requirements/base.in b/requirements/base.in index 7cf742d..bbc3663 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -2,4 +2,5 @@ futures ; python_version == "2.7" # via s3transfer mako # Used by xblockutils.resources -XBlock +simplejson +Xblock diff --git a/requirements/base.txt b/requirements/base.txt index 4e40e5a..25a8904 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -7,17 +7,21 @@ appdirs==1.4.3 # via fs backports.os==0.1.1 # via fs enum34==1.1.6 # via fs -fs==2.4.5 # via xblock -future==0.17.1 # via backports.os -futures==3.2.0 ; python_version == "2.7" -lxml==4.3.3 # via xblock -mako==1.0.10 +fs==2.4.11 # via xblock +future==0.18.2 # via backports.os +futures==3.3.0 ; python_version == "2.7" +lxml==4.4.2 # via xblock +mako==1.1.0 markupsafe==1.1.1 # via mako, xblock -python-dateutil==2.8.0 # via xblock -pytz==2019.1 # via fs, xblock -pyyaml==5.1 # via xblock -six==1.12.0 # via fs, python-dateutil, xblock -typing==3.6.6 # via fs -web-fragments==0.3.0 # via xblock +python-dateutil==2.8.1 # via xblock +pytz==2019.3 # via fs, xblock +pyyaml==5.2 # via xblock +simplejson==3.17.0 +six==1.13.0 # via fs, python-dateutil, xblock +typing==3.7.4.1 # via fs +web-fragments==0.3.1 # via xblock webob==1.8.5 # via xblock -xblock==1.2.2 +xblock==1.2.9 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/requirements/dev.txt b/requirements/dev.txt index 1fd2c85..dce4fd4 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -4,53 +4,68 @@ # # make upgrade # --e git+https://github.com/edx/xblock-sdk.git@48cb0d5066a1f5ab8eecba41bb3d63c78c985a81#egg=xblock-sdk==0.1.5 +-e git+https://github.com/edx/xblock-sdk.git@c541e4fee8c90647b136f75b404e55c04c8b67f4#egg=xblock-sdk==0.1.7 appdirs==1.4.3 +astroid==1.6.6 +backports.functools-lru-cache==1.6.1 backports.os==0.1.1 -binaryornot==0.4.4 bleach==3.1.0 -certifi==2019.3.9 -chardet==3.0.4 +click-log==0.3.2 click==7.0 -cookiecutter==0.9.0 -ddt==1.2.1 -django-nose==1.4.6 -django==1.11.20 -docutils==0.14 +configparser==4.0.2 +contextlib2==0.6.0.post1 +ddt==1.2.2 +django==1.11.26 +docutils==0.15.2 +edx-lint==1.4.1 enum34==1.1.6 filelock==3.0.12 -fs==2.4.5 +fs==2.4.11 funcsigs==1.0.2 -future==0.17.1 -futures==3.2.0 ; python_version == "2.7" -idna==2.8 -jinja2==2.10.1 -lazy==1.4 -lxml==4.3.3 -mako==1.0.10 +future==0.18.2 +futures==3.3.0 ; python_version == "2.7" +importlib-metadata==1.2.0 +isort==4.3.21 +lazy-object-proxy==1.4.3 +lxml==4.4.2 +mako==1.1.0 markupsafe==1.1.1 +mccabe==0.6.1 mock==3.0.5 -nose==1.3.7 -pip-tools==3.7.0 -pluggy==0.11.0 +more-itertools==5.0.0 +packaging==19.2 +pathlib2==2.3.5 +pip-tools==4.3.0 +pluggy==0.13.1 py==1.8.0 pycodestyle==2.5.0 -pygments==2.4.0 -pypng==0.0.19 -python-dateutil==2.8.0 -pytz==2019.1 -pyyaml==5.1 +pygments==2.5.2 +pylint-celery==0.3 +pylint-django==0.11.1 +pylint-plugin-utils==0.6 +pylint==1.9.5 +pyparsing==2.4.5 +python-dateutil==2.8.1 +pytz==2019.3 +pyyaml==5.2 readme-renderer==24.0 -requests==2.22.0 -simplejson==3.16.0 -six==1.12.0 +scandir==1.10.0 +selenium==3.141.0 +simplejson==3.17.0 +singledispatch==3.4.0.3 +six==1.13.0 toml==0.10.0 tox-battery==0.5.1 -tox==3.11.1 -typing==3.6.6 -urllib3==1.25.2 -virtualenv==16.6.0 -web-fragments==0.3.0 +tox==3.14.2 +typing==3.7.4.1 +urllib3==1.25.7 +virtualenv==16.7.8 +web-fragments==0.3.1 webencodings==0.5.1 webob==1.8.5 -xblock==1.2.2 +wrapt==1.11.2 +xblock==1.2.9 +zipp==0.6.0 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 9fb7027..12b8b2d 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -5,5 +5,5 @@ # make upgrade # click==7.0 # via pip-tools -pip-tools==3.7.0 -six==1.12.0 # via pip-tools +pip-tools==4.3.0 +six==1.13.0 # via pip-tools diff --git a/requirements/test.in b/requirements/test.in index 0ae47b3..8cc546a 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -2,8 +2,10 @@ -r base.txt # Package dependencies --e git+https://github.com/edx/xblock-sdk.git@48cb0d5066a1f5ab8eecba41bb3d63c78c985a81#egg=xblock-sdk==0.1.5 +-e git+https://github.com/edx/xblock-sdk.git@c541e4fee8c90647b136f75b404e55c04c8b67f4#egg=xblock-sdk==0.1.7 ddt +edx-lint mock pycodestyle readme_renderer +selenium \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt index bfbda35..f63e347 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,43 +4,51 @@ # # make upgrade # --e git+https://github.com/edx/xblock-sdk.git@48cb0d5066a1f5ab8eecba41bb3d63c78c985a81#egg=xblock-sdk==0.1.5 +-e git+https://github.com/edx/xblock-sdk.git@c541e4fee8c90647b136f75b404e55c04c8b67f4#egg=xblock-sdk==0.1.7 appdirs==1.4.3 +astroid==1.6.6 # via pylint, pylint-celery +backports.functools-lru-cache==1.6.1 # via astroid, isort, pylint backports.os==0.1.1 -binaryornot==0.4.4 # via cookiecutter bleach==3.1.0 # via readme-renderer -certifi==2019.3.9 # via requests -chardet==3.0.4 # via binaryornot, requests -cookiecutter==0.9.0 -ddt==1.2.1 -django-nose==1.4.6 -docutils==0.14 # via readme-renderer +click-log==0.3.2 # via edx-lint +click==7.0 # via click-log, edx-lint +configparser==4.0.2 # via pylint +ddt==1.2.2 +docutils==0.15.2 # via readme-renderer +edx-lint==1.4.1 enum34==1.1.6 -fs==2.4.5 +fs==2.4.11 funcsigs==1.0.2 # via mock -future==0.17.1 -futures==3.2.0 ; python_version == "2.7" -idna==2.8 # via requests -jinja2==2.10.1 # via cookiecutter -lazy==1.4 -lxml==4.3.3 -mako==1.0.10 +future==0.18.2 +futures==3.3.0 ; python_version == "2.7" +isort==4.3.21 # via pylint +lazy-object-proxy==1.4.3 # via astroid +lxml==4.4.2 +mako==1.1.0 markupsafe==1.1.1 +mccabe==0.6.1 # via pylint mock==3.0.5 -nose==1.3.7 # via django-nose pycodestyle==2.5.0 -pygments==2.4.0 # via readme-renderer -pypng==0.0.19 -python-dateutil==2.8.0 -pytz==2019.1 -pyyaml==5.1 +pygments==2.5.2 # via readme-renderer +pylint-celery==0.3 # via edx-lint +pylint-django==0.11.1 # via edx-lint +pylint-plugin-utils==0.6 # via pylint-celery, pylint-django +pylint==1.9.5 # via edx-lint, pylint-celery, pylint-django, pylint-plugin-utils +python-dateutil==2.8.1 +pytz==2019.3 +pyyaml==5.2 readme-renderer==24.0 -requests==2.22.0 -simplejson==3.16.0 -six==1.12.0 -typing==3.6.6 -urllib3==1.25.2 # via requests -web-fragments==0.3.0 +selenium==3.141.0 +simplejson==3.17.0 +singledispatch==3.4.0.3 # via astroid, pylint +six==1.13.0 +typing==3.7.4.1 +urllib3==1.25.7 # via selenium +web-fragments==0.3.1 webencodings==0.5.1 # via bleach webob==1.8.5 -xblock==1.2.2 +wrapt==1.11.2 # via astroid +xblock==1.2.9 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/requirements/travis.txt b/requirements/travis.txt index 74c950c..1b724d4 100644 --- a/requirements/travis.txt +++ b/requirements/travis.txt @@ -4,11 +4,20 @@ # # make upgrade # +configparser==4.0.2 # via importlib-metadata +contextlib2==0.6.0.post1 # via importlib-metadata filelock==3.0.12 # via tox -pluggy==0.11.0 # via tox +importlib-metadata==1.2.0 # via pluggy, tox +more-itertools==5.0.0 # via zipp +packaging==19.2 # via tox +pathlib2==2.3.5 # via importlib-metadata +pluggy==0.13.1 # via tox py==1.8.0 # via tox -six==1.12.0 # via tox +pyparsing==2.4.5 # via packaging +scandir==1.10.0 # via pathlib2 +six==1.13.0 # via more-itertools, packaging, pathlib2, tox toml==0.10.0 # via tox tox-battery==0.5.1 -tox==3.11.1 -virtualenv==16.6.0 # via tox +tox==3.14.2 +virtualenv==16.7.8 # via tox +zipp==0.6.0 # via importlib-metadata diff --git a/setup.py b/setup.py index c128646..c508c31 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def is_requirement(line): README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read() -VERSION = '1.2.2' +VERSION = '1.2.3' if sys.argv[-1] == 'tag': print("Tagging the version on github:") diff --git a/tests/unit/test_publish_event.py b/tests/unit/test_publish_event.py index 16df32f..8e9bf04 100644 --- a/tests/unit/test_publish_event.py +++ b/tests/unit/test_publish_event.py @@ -20,7 +20,7 @@ from __future__ import absolute_import import unittest -import json +import simplejson as json from xblockutils.publish_event import PublishEventMixin @@ -33,7 +33,7 @@ class RequestMock(object): method = "POST" def __init__(self, data): - self.body = json.dumps(data) + self.body = json.dumps(data).encode('utf-8') class RuntimeMock(object): diff --git a/tox.ini b/tox.ini index 9ec2407..d965a1c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{27,36,37}-django{111,20,21} +envlist = py{27,35}-django111,py35-django{20,21,22} [pycodestyle] # error codes: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes @@ -30,15 +30,16 @@ commands = django111: pip install Django>=1.11,<2.0 django20: pip install Django>=2.0,<2.1 django21: pip install Django>=2.1,<2.2 - python ./run_tests.py --with-coverage --cover-package=xblockutils {posargs} + django22: pip install Django>=2.2,<2.3 + python ./run_tests.py [testenv:quality] -basepython = python2.7 +basepython = python3.5 deps = {[base]deps} commands = {[base]commands} - pip install Django>=1.11,<2.2 + pip install Django>=1.11,<2.3 pycodestyle . pylint xblockutils python setup.py check -r -s diff --git a/xblockutils/base_test.py b/xblockutils/base_test.py index 5d04ea3..2429367 100644 --- a/xblockutils/base_test.py +++ b/xblockutils/base_test.py @@ -44,7 +44,7 @@ class SeleniumXBlockTest(SeleniumTest): def setUp(self): super(SeleniumXBlockTest, self).setUp() # Delete all scenarios from the workbench: - import workbench.urls # Trigger initial scenario load. pylint: disable=unused-variable + import workbench.urls # Trigger initial scenario load. SCENARIOS.clear() # Disable CSRF checks on XBlock handlers: import workbench.views diff --git a/xblockutils/publish_event.py b/xblockutils/publish_event.py index 2d9a11d..2e76a89 100644 --- a/xblockutils/publish_event.py +++ b/xblockutils/publish_event.py @@ -34,7 +34,7 @@ class PublishEventMixin(object): additional_publish_event_data = {} @XBlock.json_handler - def publish_event(self, data, suffix=''): + def publish_event(self, data, suffix=''): # pylint: disable=unused-argument """ AJAX handler to allow client-side code to publish a server-side event """ diff --git a/xblockutils/resources.py b/xblockutils/resources.py index ca38eaa..e8ab437 100644 --- a/xblockutils/resources.py +++ b/xblockutils/resources.py @@ -65,7 +65,7 @@ def render_django_template(self, template_path, context=None, i18n_service=None) if django.VERSION[0] == 1 and django.VERSION[1] == 8: _libraries = TemplateBase.libraries.copy() for library_name in libraries: - library = TemplateBase.import_library(libraries[library_name]) + library = TemplateBase.import_library(libraries[library_name]) # pylint: disable=no-member if library: TemplateBase.libraries[library_name] = library engine = Engine() @@ -113,7 +113,7 @@ def render_js_template(self, template_path, element_id, context=None): context = context or {} return u"".format( element_id, - self.render_template(template_path, context) + self.render_django_template(template_path, context) ) def load_scenarios_from_path(self, relative_scenario_dir, include_identifier=False): @@ -134,7 +134,7 @@ def load_scenarios_from_path(self, relative_scenario_dir, include_identifier=Fal identifier = template[:-4] title = identifier.replace('_', ' ').title() template_path = os.path.join(relative_scenario_dir, template) - scenario = text_type(self.render_template(template_path, {"url_name": identifier})) + scenario = text_type(self.render_django_template(template_path, {"url_name": identifier})) if not include_identifier: scenarios.append((title, scenario)) else: diff --git a/xblockutils/studio_editable.py b/xblockutils/studio_editable.py index 827b89b..d48c14b 100644 --- a/xblockutils/studio_editable.py +++ b/xblockutils/studio_editable.py @@ -11,8 +11,8 @@ # Imports ########################################################### from __future__ import absolute_import -import json import logging +import simplejson as json import six from six import text_type @@ -92,12 +92,12 @@ def studio_view(self, context): field_info = self._make_field_info(field_name, field) if field_info is not None: context["fields"].append(field_info) - fragment.content = loader.render_template('templates/studio_edit.html', context) + fragment.content = loader.render_django_template('templates/studio_edit.html', context) fragment.add_javascript(loader.load_unicode('public/studio_edit.js')) fragment.initialize_js('StudioEditableXBlockMixin') return fragment - def _make_field_info(self, field_name, field): + def _make_field_info(self, field_name, field): # pylint: disable=too-many-statements """ Create the information that the template needs to render a form field for this field. """ @@ -120,11 +120,13 @@ def ugettext(text): info = { 'name': field_name, + # pylint: disable=translation-of-non-string 'display_name': ugettext(field.display_name) if field.display_name else "", 'is_set': field.is_set_on(self), 'default': field.default, 'value': field.read_from(self), 'has_values': False, + # pylint: disable=translation-of-non-string 'help': ugettext(field.help) if field.help else "", 'allow_reset': field.runtime_options.get('resettable_editor', True), 'list_values': None, # Only available for List fields @@ -202,7 +204,7 @@ def ugettext(text): return info @XBlock.json_handler - def submit_studio_edits(self, data, suffix=''): + def submit_studio_edits(self, data, suffix=''): # pylint: disable=unused-argument """ AJAX handler for studio_view() Save button """ @@ -244,7 +246,6 @@ def clean_studio_edits(self, data): # Example: # if "name" in data: # data["name"] = data["name"].strip() - pass def validate_field_data(self, validation, data): """ @@ -259,7 +260,6 @@ def validate_field_data(self, validation, data): # Example: # if data.count <=0: # validation.add(ValidationMessage(ValidationMessage.ERROR, u"Invalid count")) - pass def validate(self): """ @@ -421,14 +421,14 @@ class StudioContainerWithNestedXBlocksMixin(StudioContainerXBlockMixin): CHILD_PREVIEW_TEMPLATE = "templates/default_preview_view.html" @property - def loader(self): # pylint: disable=no-self-use + def loader(self): """ Loader for loading and rendering assets stored in child XBlock package """ return loader @property - def allowed_nested_blocks(self): # pylint: disable=no-self-use + def allowed_nested_blocks(self): """ Returns a list of allowed nested XBlocks. Each item can be either * An XBlock class @@ -463,7 +463,10 @@ def author_edit_view(self, context): if 'wrap_children' in context: fragment.add_content(context['wrap_children']['tail']) fragment.add_content( - loader.render_template('templates/add_buttons.html', {'child_blocks': self.get_nested_blocks_spec()}) + loader.render_django_template( + 'templates/add_buttons.html', + {'child_blocks': self.get_nested_blocks_spec()} + ) ) fragment.add_javascript(loader.load_unicode('public/studio_container.js')) fragment.initialize_js('StudioContainerXBlockWithNestedXBlocksMixin') @@ -487,7 +490,7 @@ def author_preview_view(self, context): 'children_contents': children_contents } render_context.update(context) - fragment.add_content(self.loader.render_template(self.CHILD_PREVIEW_TEMPLATE, render_context)) + fragment.add_content(self.loader.render_django_template(self.CHILD_PREVIEW_TEMPLATE, render_context)) return fragment def _render_child_fragment(self, child, context, view='student_view'): diff --git a/xblockutils/templatetags/i18n.py b/xblockutils/templatetags/i18n.py index 48a545c..6653a2d 100644 --- a/xblockutils/templatetags/i18n.py +++ b/xblockutils/templatetags/i18n.py @@ -44,7 +44,7 @@ def merge_translation(self, context): # Revert to original translation object if language in self._translations: - trans_real._translations[language] = self._translations[language] + trans_real._translations[language] = self._translations[language] # pylint: disable=protected-access # Re-activate the current language to reset translation caches trans_real.activate(language)