diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a6ad58c..cc66140 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,7 @@ jobs: - ["3.8", "py38"] - ["3.9", "py39"] - ["3.10", "py310"] + - ["3.11.0-alpha.6", "py311"] - ["3.9", "docs"] - ["3.9", "coverage"] - ["3.9", "py39-datetime"] diff --git a/.gitignore b/.gitignore index c724a76..1f321f5 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ lib64 log/ parts/ pyvenv.cfg +testing.log var/ diff --git a/.meta.toml b/.meta.toml index 2829af8..2d9555e 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,7 +2,7 @@ # https://github.com/zopefoundation/meta/tree/master/config/pure-python [meta] template = "pure-python" -commit-id = "886173bf647a6e80a985544c32053c932b1949e2" +commit-id = "3a251aab94eff9cf2aa2fd87d7266593251e4b76" [python] with-pypy = false @@ -10,7 +10,7 @@ with-legacy-python = true with-docs = true with-sphinx-doctests = true with-windows = true -with-future-python = false +with-future-python = true [tox] use-flake8 = true @@ -41,8 +41,6 @@ testenv-additional = [ "deps =", " coverage", " coverage-python-version", - " # Until repoze.sphinx.autointerface supports Sphinx 4.x we cannot use it:", - " Sphinx < 4", " -cconstraints.txt", "setenv =", " COVERAGE_FILE=.coverage", diff --git a/CHANGES.rst b/CHANGES.rst index 3f19ece..73b6525 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changes 5.3 (unreleased) ---------------- -- Nothing changed yet. +- Allow to use the package with Python 3.11 -- Caution: No security audit has + been done so far. 5.2 (2021-11-19) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..31d95f0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,23 @@ + +# Contributing to zopefoundation projects + +The projects under the zopefoundation GitHub organization are open source and +welcome contributions in different forms: + +* bug reports +* code improvements and bug fixes +* documentation improvements +* pull request reviews + +For any changes in the repository besides trivial typo fixes you are required +to sign the contributor agreement. See +https://www.zope.dev/developer/becoming-a-committer.html for details. + +Please visit our [Developer +Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to +contribute code changes and our [guidelines for reporting +bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a +bug report. diff --git a/MANIFEST.in b/MANIFEST.in index 8b503ff..a1bb705 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/pure-python +include *.md include *.rst include *.txt include buildout.cfg diff --git a/constraints.txt b/constraints.txt index 083bd89..72b9dad 100644 --- a/constraints.txt +++ b/constraints.txt @@ -3,8 +3,11 @@ # Pin Versions / Version Ranges if necessary. isort >= 4.3.2 # Needed for Appveyor as long as PY2 is supported: -pytest < 5 -pytest-html < 2 +pytest < 5 ; python_version < '3.11' +# Python 3.11 needs pytest > 5 +pytest >= 5 ; python_version >= '3.11' # coverage 6+ no longer supports Python 2 and coverage results of older # versions cannot not combined with newer ones: -coverage < 6 +coverage < 6; python_version < '3.11' +# Python 3.11 requires coverage >= 6, +coverage >= 6; python_version >= '3.11' diff --git a/setup.cfg b/setup.cfg index b949ede..4105f22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,3 +19,14 @@ ignore = docs/_build/html/_sources/roadmap/* docs/_build/html/_sources/upgrade_dependencies/* docs/_build/html/_sources/usage/* + +[isort] +force_single_line = True +combine_as_imports = True +sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER +known_third_party = six, docutils, pkg_resources +known_zope = +known_first_party = +default_section = ZOPE +line_length = 79 +lines_after_imports = 2 diff --git a/setup.py b/setup.py index 497a923..2584e74 100644 --- a/setup.py +++ b/setup.py @@ -13,11 +13,11 @@ ############################################################################## """Setup for RestrictedPython package""" +import os + from setuptools import find_packages from setuptools import setup -import os - def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: @@ -70,7 +70,7 @@ def read(*rnames): package_dir={'': 'src'}, install_requires=[ ], - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11", # NOQA: E501 + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.12", # NOQA: E501 tests_require=tests_require, extras_require={ 'test': tests_require, diff --git a/src/RestrictedPython/Eval.py b/src/RestrictedPython/Eval.py index a95677b..d3a4011 100644 --- a/src/RestrictedPython/Eval.py +++ b/src/RestrictedPython/Eval.py @@ -12,11 +12,11 @@ ############################################################################## """Restricted Python Expressions.""" +import ast + from ._compat import IS_PY2 from .compile import compile_restricted_eval -import ast - if IS_PY2: # pragma: PY2 from string import maketrans diff --git a/src/RestrictedPython/compile.py b/src/RestrictedPython/compile.py index 3fc2881..465a8c0 100644 --- a/src/RestrictedPython/compile.py +++ b/src/RestrictedPython/compile.py @@ -1,11 +1,11 @@ +import ast +import warnings from collections import namedtuple + from RestrictedPython._compat import IS_CPYTHON from RestrictedPython._compat import IS_PY2 from RestrictedPython.transformer import RestrictingNodeTransformer -import ast -import warnings - CompileResult = namedtuple( 'CompileResult', 'code, errors, warnings, used_names') diff --git a/src/RestrictedPython/transformer.py b/src/RestrictedPython/transformer.py index 1b80186..6b229b4 100644 --- a/src/RestrictedPython/transformer.py +++ b/src/RestrictedPython/transformer.py @@ -22,16 +22,16 @@ # http://docs.plone.org/develop/styleguide/python.html +import ast +import contextlib +import textwrap + from ._compat import IS_PY2 from ._compat import IS_PY3 from ._compat import IS_PY34_OR_GREATER from ._compat import IS_PY35_OR_GREATER from ._compat import IS_PY38_OR_GREATER -import ast -import contextlib -import textwrap - # For AugAssign the operator must be converted to a string. IOPERATOR_TO_STR = { diff --git a/tox.ini b/tox.ini index 3710776..517bd01 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ envlist = py38 py39 py310 + py311 docs coverage py39-datetime @@ -22,7 +23,7 @@ deps = datetime: DateTime -cconstraints.txt pytest-cov - coverage-python-version + !py311: coverage-python-version setenv = COVERAGE_FILE=.coverage.{envname} commands = @@ -41,8 +42,6 @@ allowlist_externals = deps = coverage coverage-python-version - # Until repoze.sphinx.autointerface supports Sphinx 4.x we cannot use it: - Sphinx < 4 -cconstraints.txt setenv = COVERAGE_FILE=.coverage @@ -56,15 +55,25 @@ depends = py27,py35,py36,py37,py38,py39,py39-datetime,py310,coverage [testenv:lint] basepython = python3 skip_install = true +commands = + isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py + flake8 src setup.py + check-manifest + check-python-versions deps = - flake8 check-manifest check-python-versions >= 0.19.1 wheel + flake8 + isort + +[testenv:isort-apply] +basepython = python3 +commands_pre = +deps = + isort commands = - flake8 src setup.py - check-manifest - check-python-versions + isort {toxinidir}/src {toxinidir}/setup.py [] [testenv:docs] basepython = python3 @@ -96,7 +105,6 @@ commands = [coverage:run] branch = True -plugins = coverage_python_version source = RestrictedPython [coverage:report]