diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 312d099..318910e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -11,13 +11,13 @@ repos: - id: debug-statements language_version: python3 - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 language_version: python3 - additional_dependencies: [flake8-typing-imports==1.14.0] + additional_dependencies: [flake8-typing-imports==1.15.0] - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v2.0.1 + rev: v2.0.4 hooks: - id: autopep8 - repo: https://github.com/timothycrosley/isort @@ -38,7 +38,7 @@ repos: additional_dependencies: [pygments, restructuredtext_lint] # This can deal with sphinx directives - repo: https://github.com/myint/rstcheck - rev: "v6.1.1" + rev: "v6.2.0" hooks: - id: rstcheck args: [--ignore-messages, Duplicate implicit target.*] diff --git a/config/README.rst b/config/README.rst index 58b8062..fb28d48 100644 --- a/config/README.rst +++ b/config/README.rst @@ -271,6 +271,9 @@ updated. Example: " src/foo/bar.py: E221 E222", "extend-ignore = D203, W503", ] + additional-plugins = [ + "mccabe", + ] additional-sources = "testproj foo bar.py" [manifest] @@ -522,6 +525,10 @@ additional-config list of strings so the leading white spaces and comments are preserved when writing the value to ``setup.cfg``. +additional-plugins + Some packages want to have additional flake8 plugins installed. + This option is a list of strings. + additional-sources Sometimes not only ``src`` and ``setup.py`` contain Python code to be checked by flake8. Additional files or directories can be configured here. This diff --git a/config/config-package.py b/config/config-package.py index 1f3d228..739b39c 100755 --- a/config/config-package.py +++ b/config/config-package.py @@ -22,7 +22,7 @@ Generated from: https://github.com/zopefoundation/meta/tree/master/config/{config_type} --> """ -FUTURE_PYTHON_VERSION = "" +FUTURE_PYTHON_VERSION = "3.13.0-alpha - 3.13.0" DEFAULT = object() @@ -226,10 +226,7 @@ def with_pypy(self): @cached_property def with_future_python(self): - if FUTURE_PYTHON_VERSION: - return self._set_python_config_value('future-python') - else: - return False + return self._set_python_config_value('future-python') @cached_property def with_docs(self): @@ -423,6 +420,8 @@ def tox(self): coverage_setenv = self.tox_option('coverage-setenv') coverage_run_additional_config = self.meta_cfg['coverage-run'].get( 'additional-config', []) + flake8_additional_plugins = self.meta_cfg['flake8'].get( + 'additional-plugins', '') flake8_additional_sources = self.meta_cfg['flake8'].get( 'additional-sources', '') if flake8_additional_sources: @@ -454,6 +453,7 @@ def tox(self): coverage_setenv=coverage_setenv, fail_under=self.fail_under, flake8_additional_sources=flake8_additional_sources, + flake8_additional_plugins=flake8_additional_plugins, isort_additional_sources=isort_additional_sources, testenv_additional=testenv_additional, testenv_additional_extras=testenv_additional_extras, diff --git a/config/default/tests.yml.j2 b/config/default/tests.yml.j2 index e6877a3..547dc68 100644 --- a/config/default/tests.yml.j2 +++ b/config/default/tests.yml.j2 @@ -35,6 +35,7 @@ jobs: {% endif %} config: # [Python version, tox env] + - ["3.9", "release-check"] - ["3.9", "lint"] - ["3.7", "py37"] - ["3.8", "py38"] @@ -61,6 +62,7 @@ jobs: exclude: {% endif %} {% if with_windows %} + - { os: ["windows", "windows-latest"], config: ["3.9", "release-check"] } - { os: ["windows", "windows-latest"], config: ["3.9", "lint"] } {% if with_docs %} - { os: ["windows", "windows-latest"], config: ["3.9", "docs"] } @@ -68,6 +70,7 @@ jobs: - { os: ["windows", "windows-latest"], config: ["3.9", "coverage"] } {% endif %} {% if with_macos %} + - { os: ["macos", "macos-11"], config: ["3.9", "release-check"] } - { os: ["macos", "macos-11"], config: ["3.9", "lint"] } {% if with_docs %} - { os: ["macos", "macos-11"], config: ["3.9", "docs"] } diff --git a/config/default/tox-envlist.j2 b/config/default/tox-envlist.j2 index 9a6ae42..199cb60 100644 --- a/config/default/tox-envlist.j2 +++ b/config/default/tox-envlist.j2 @@ -1,6 +1,7 @@ [tox] minversion = 3.18 envlist = + release-check lint py37 py38 diff --git a/config/default/tox-lint.j2 b/config/default/tox-lint.j2 index 519edd8..ad095cf 100644 --- a/config/default/tox-lint.j2 +++ b/config/default/tox-lint.j2 @@ -1,21 +1,35 @@ - -[testenv:lint] +[testenv:release-check] +description = ensure that the distribution is ready to release basepython = python3 skip_install = true +deps = + twine + build + check-manifest + check-python-versions >= 0.20.0 + wheel commands = -{% if use_flake8 %} - isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py%(isort_additional_sources)s - flake8 src setup.py%(flake8_additional_sources)s -{% endif %} check-manifest check-python-versions + python -m build --sdist --no-isolation + twine check dist/* + +[testenv:lint] +basepython = python3 +skip_install = true deps = - check-manifest - check-python-versions >= 0.19.1 - wheel + isort {% if use_flake8 %} flake8 - isort +{% for line in flake8_additional_plugins %} + %(line)s +{% endfor %} +{% endif %} +commands = + isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py%(isort_additional_sources)s +{% if use_flake8 %} + flake8 src setup.py%(flake8_additional_sources)s +{% endif %} [testenv:isort-apply] basepython = python3 @@ -25,4 +39,3 @@ deps = isort commands = isort {toxinidir}/src {toxinidir}/setup.py%(isort_additional_sources)s [] -{% endif %} diff --git a/config/zope-product/tox.ini.j2 b/config/zope-product/tox.ini.j2 index 532ae08..10d932e 100644 --- a/config/zope-product/tox.ini.j2 +++ b/config/zope-product/tox.ini.j2 @@ -31,12 +31,29 @@ commands = %(line)s {% endfor %} {% else %} - {envdir}/bin/test {posargs:-cv} + {envbindir}/test {posargs:-cv} {% endif %} {% for line in testenv_additional %} %(line)s {% endfor %} +[testenv:release-check] +description = ensure that the distribution is ready to release +basepython = python3 +skip_install = true +deps = + twine + build + check-manifest + check-python-versions >= 0.20.0 + wheel +commands_pre = +commands = + check-manifest + check-python-versions + python -m build --sdist --no-isolation + twine check dist/* + [testenv:lint] basepython = python3 commands_pre = @@ -50,11 +67,7 @@ commands = isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py%(isort_additional_sources)s flake8 {toxinidir}/src {toxinidir}/setup.py%(flake8_additional_sources)s {% endif %} - check-manifest - check-python-versions deps = - check-manifest - check-python-versions {% if use_flake8 %} flake8 isort @@ -95,7 +108,7 @@ commands = %(line)s {% endfor %} {% else %} - coverage run {envdir}/bin/test {posargs:-cv} + coverage run {envbindir}/test {posargs:-cv} {% endif %} coverage html coverage report -m --fail-under=%(fail_under)s