From c38ee2979c7c2b3a0ef3bad62f69f01501d47704 Mon Sep 17 00:00:00 2001 From: ale-rt Date: Fri, 29 Nov 2024 17:39:18 +0100 Subject: [PATCH] Configuring with plone/meta --- .editorconfig | 11 +- .flake8 | 22 +++ .github/workflows/meta.yml | 75 ++++++++++ .gitignore | 10 +- .meta.toml | 6 + .pre-commit-config.yaml | 28 ++-- MANIFEST.in | 6 + dependabot.yml | 11 ++ pyproject.toml | 131 +++++++++++++++++ setup.cfg | 24 ---- src/collective/pdbpp/__init__.py | 1 - tox.ini | 238 ++++++++++++++++++++++++------- 12 files changed, 474 insertions(+), 89 deletions(-) create mode 100644 .flake8 create mode 100644 .github/workflows/meta.yml create mode 100644 .meta.toml create mode 100644 dependabot.yml create mode 100644 pyproject.toml diff --git a/.editorconfig b/.editorconfig index 919b411..5b3c112 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/main/config/default # See the inline comments on how to expand/tweak this configuration file # # EditorConfig Configuration file, for more details see: @@ -13,7 +13,8 @@ root = true -[*] # For All Files +[*] +# Default settings for all files. # Unix-style newlines with a newline ending every file end_of_line = lf insert_final_newline = true @@ -29,13 +30,15 @@ max_line_length = off # 4 space indentation indent_size = 4 -[*.{yml,zpt,pt,dtml,zcml}] +[*.{yml,zpt,pt,dtml,zcml,html,xml}] # 2 space indentation indent_size = 2 -[*.{json,jsonl,js,jsx,ts,tsx,css,less,scss,html}] # Frontend development +[*.{json,jsonl,js,jsx,ts,tsx,css,less,scss}] +# Frontend development # 2 space indentation indent_size = 2 +max_line_length = 80 [{Makefile,.gitmodules}] # Tab indentation (no size specified, but view as 4 spaces) diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..38918f4 --- /dev/null +++ b/.flake8 @@ -0,0 +1,22 @@ +# Generated from: +# https://github.com/plone/meta/tree/main/config/default +# See the inline comments on how to expand/tweak this configuration file +[flake8] +doctests = 1 +ignore = + # black takes care of line length + E501, + # black takes care of where to break lines + W503, + # black takes care of spaces within slicing (list[:]) + E203, + # black takes care of spaces after commas + E231, + +## +# Add extra configuration options in .meta.toml: +# [flake8] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml new file mode 100644 index 0000000..c9848bc --- /dev/null +++ b/.github/workflows/meta.yml @@ -0,0 +1,75 @@ +# Generated from: +# https://github.com/plone/meta/tree/main/config/default +# See the inline comments on how to expand/tweak this configuration file +name: Meta +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + workflow_dispatch: + +## +# To set environment variables for all jobs, add in .meta.toml: +# [github] +# env = """ +# debug: 1 +# image-name: 'org/image' +# image-tag: 'latest' +# """ +## + +jobs: + qa: + uses: plone/meta/.github/workflows/qa.yml@main + test: + uses: plone/meta/.github/workflows/test.yml@main + coverage: + uses: plone/meta/.github/workflows/coverage.yml@main + dependencies: + uses: plone/meta/.github/workflows/dependencies.yml@main + release_ready: + uses: plone/meta/.github/workflows/release_ready.yml@main + circular: + uses: plone/meta/.github/workflows/circular.yml@main + +## +# To modify the list of default jobs being created add in .meta.toml: +# [github] +# jobs = [ +# "qa", +# "test", +# "coverage", +# "dependencies", +# "release_ready", +# "circular", +# ] +## + +## +# To request that some OS level dependencies get installed +# when running tests/coverage jobs, add in .meta.toml: +# [github] +# os_dependencies = "git libxml2 libxslt" +## + +## +# To test against a specific matrix of python versions +# when running tests jobs, add in .meta.toml: +# [github] +# py_versions = "['3.12', '3.11']" +## + + +## +# Specify additional jobs in .meta.toml: +# [github] +# extra_lines = """ +# another: +# uses: org/repo/.github/workflows/file.yml@main +# """ +## diff --git a/.gitignore b/.gitignore index 110f70b..8f05622 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,18 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/main/config/default # See the inline comments on how to expand/tweak this configuration file # python related *.egg-info *.pyc *.pyo +# translation related +*.mo + # tools related build/ .coverage -.coverage.* +.*project coverage.xml dist/ docs/_build @@ -17,6 +20,8 @@ __pycache__/ .tox .vscode/ node_modules/ +forest.dot +forest.json # venv / buildout related bin/ @@ -32,6 +37,7 @@ lib64 parts/ pyvenv.cfg var/ +local.cfg # mxdev /instance/ diff --git a/.meta.toml b/.meta.toml new file mode 100644 index 0000000..98d09a2 --- /dev/null +++ b/.meta.toml @@ -0,0 +1,6 @@ +# Generated from: +# https://github.com/plone/meta/tree/main/config/default +# See the inline comments on how to expand/tweak this configuration file +[meta] +template = "default" +commit-id = "d03b196d" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7de9fd7..1460326 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/main/config/default # See the inline comments on how to expand/tweak this configuration file ci: autofix_prs: false @@ -7,20 +7,20 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.4.0 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/collective/zpretty - rev: 3.1.0a2 + rev: 3.1.0 hooks: - id: zpretty @@ -32,7 +32,7 @@ repos: # """ ## - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.1.1 hooks: - id: flake8 @@ -44,7 +44,7 @@ repos: # """ ## - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.3.0 hooks: - id: codespell additional_dependencies: @@ -66,15 +66,25 @@ repos: hooks: - id: pyroma - repo: https://github.com/mgedmin/check-python-versions - rev: "0.21.2" + rev: "0.22.0" hooks: - id: check-python-versions args: ['--only', 'setup.py,pyproject.toml'] - repo: https://github.com/collective/i18ndude - rev: "6.0.0" + rev: "6.2.1" hooks: - id: i18ndude + +## +# Add extra configuration options in .meta.toml: +# [pre_commit] +# i18ndude_extra_lines = """ +# _your own configuration lines_ +# """ +## + + ## # Add extra configuration options in .meta.toml: # [pre_commit] diff --git a/MANIFEST.in b/MANIFEST.in index 5142e72..6ede087 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,3 +5,9 @@ include *.yaml exclude tox.ini exclude *.txt global-exclude *.pyc +exclude .coveragerc +exclude base.cfg +exclude bobtemplate.cfg +exclude buildout.cfg +exclude test_plone52.cfg +exclude test_plone60.cfg diff --git a/dependabot.yml b/dependabot.yml new file mode 100644 index 0000000..bbd3ab0 --- /dev/null +++ b/dependabot.yml @@ -0,0 +1,11 @@ +# Generated from: +# https://github.com/plone/meta/tree/main/config/default +# See the inline comments on how to expand/tweak this configuration file +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every week + interval: "weekly" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..16e4e0a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,131 @@ +# Generated from: +# https://github.com/plone/meta/tree/main/config/default +# See the inline comments on how to expand/tweak this configuration file +[build-system] +requires = ["setuptools>=68.2"] + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# towncrier_extra_lines = """ +# extra_configuration +# """ +## + +[tool.isort] +profile = "plone" + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# isort_extra_lines = """ +# extra_configuration +# """ +## + +[tool.black] +target-version = ["py38"] + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# black_extra_lines = """ +# extra_configuration +# """ +## + +[tool.codespell] +ignore-words-list = "discreet,assertin," +skip = "*.po," +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# codespell_ignores = "foo,bar" +# codespell_skip = "*.po,*.map,package-lock.json" +## + +[tool.dependencychecker] +Zope = [ + # Zope own provided namespaces + 'App', 'OFS', 'Products.Five', 'Products.OFSP', 'Products.PageTemplates', + 'Products.SiteAccess', 'Shared', 'Testing', 'ZPublisher', 'ZTUtils', + 'Zope2', 'webdav', 'zmi', + # ExtensionClass own provided namespaces + 'ExtensionClass', 'ComputedAttribute', 'MethodObject', + # Zope dependencies + 'AccessControl', 'Acquisition', 'AuthEncoding', 'beautifulsoup4', 'BTrees', + 'cffi', 'Chameleon', 'DateTime', 'DocumentTemplate', + 'MultiMapping', 'multipart', 'PasteDeploy', 'Persistence', 'persistent', + 'pycparser', 'python-gettext', 'pytz', 'RestrictedPython', 'roman', + 'soupsieve', 'transaction', 'waitress', 'WebOb', 'WebTest', 'WSGIProxy2', + 'z3c.pt', 'zc.lockfile', 'ZConfig', 'zExceptions', 'ZODB', 'zodbpickle', + 'zope.annotation', 'zope.browser', 'zope.browsermenu', 'zope.browserpage', + 'zope.browserresource', 'zope.cachedescriptors', 'zope.component', + 'zope.configuration', 'zope.container', 'zope.contentprovider', + 'zope.contenttype', 'zope.datetime', 'zope.deferredimport', + 'zope.deprecation', 'zope.dottedname', 'zope.event', 'zope.exceptions', + 'zope.filerepresentation', 'zope.globalrequest', 'zope.hookable', + 'zope.i18n', 'zope.i18nmessageid', 'zope.interface', 'zope.lifecycleevent', + 'zope.location', 'zope.pagetemplate', 'zope.processlifetime', 'zope.proxy', + 'zope.ptresource', 'zope.publisher', 'zope.schema', 'zope.security', + 'zope.sequencesort', 'zope.site', 'zope.size', 'zope.structuredtext', + 'zope.tal', 'zope.tales', 'zope.testbrowser', 'zope.testing', + 'zope.traversing', 'zope.viewlet' +] +'Products.CMFCore' = [ + 'docutils', 'five.localsitemanager', 'Missing', 'Products.BTreeFolder2', + 'Products.GenericSetup', 'Products.MailHost', 'Products.PythonScripts', + 'Products.StandardCacheManagers', 'Products.ZCatalog', 'Record', + 'zope.sendmail', 'Zope' +] +'plone.base' = [ + 'plone.batching', 'plone.registry', 'plone.schema','plone.z3cform', + 'Products.CMFCore', 'Products.CMFDynamicViewFTI', +] +python-dateutil = ['dateutil'] +pytest-plone = ['pytest', 'zope.pytestlayer', 'plone.testing', 'plone.app.testing'] + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# dependencies_ignores = "['zestreleaser.towncrier']" +# dependencies_mappings = [ +# "gitpython = ['git']", +# "pygithub = ['github']", +# ] +## + +[tool.check-manifest] +ignore = [ + ".editorconfig", + ".flake8", + ".meta.toml", + ".pre-commit-config.yaml", + "dependabot.yml", + "mx.ini", + "tox.ini", + +] + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# check_manifest_ignores = """ +# "*.map.js", +# "*.pyc", +# """ +# check_manifest_extra_lines = """ +# ignore-bad-ideas = [ +# "some/test/file/PKG-INFO", +# ] +# """ +## + + +## +# Add extra configuration options in .meta.toml: +# [pyproject] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/setup.cfg b/setup.cfg index 7f3f5c2..54bf953 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,27 +1,3 @@ -[check-manifest] -ignore = - *.cfg - .coveragerc - .editorconfig - .gitattributes - [isort] # black compatible isort rules: profile = plone - -[flake8] -# black compatible flake8 rules: -ignore = - W503, - C812, - E501 - T001 - C813 - C101 -# E203, E266 -exclude = bootstrap.py,docs,*.egg.,omelette -max-line-length = 88 -max-complexity = 18 -select = B,C,E,F,W,T4,B9 - -builtins = unicode,basestring diff --git a/src/collective/pdbpp/__init__.py b/src/collective/pdbpp/__init__.py index 29ad4e2..0f87d62 100644 --- a/src/collective/pdbpp/__init__.py +++ b/src/collective/pdbpp/__init__.py @@ -27,7 +27,6 @@ def _do_pp(self, arg): self._original_do_pp(arg) - Pdb._original_do_pp = Pdb.do_pp Pdb.do_pp = _do_pp diff --git a/tox.ini b/tox.ini index 1d8d958..0fbd258 100644 --- a/tox.ini +++ b/tox.ini @@ -1,75 +1,215 @@ +# Generated from: +# https://github.com/plone/meta/tree/main/config/default +# See the inline comments on how to expand/tweak this configuration file [tox] +# We need 4.4.0 for constrain_package_deps. +min_version = 4.4.0 envlist = - py38-Plone{52}, - py{39,310,311}-Plone{60}, - -skip_missing_interpreters = True - - -[gh-actions] -python = - 3.8: py38 - 3.9: py39 - 3.10: py310 - 3.11: py311 + lint + test + dependencies -[gh-actions:env] -PLONE-VERSION = - Plone52: Plone52 - Plone60: Plone60 +## +# Add extra configuration options in .meta.toml: +# [tox] +# envlist_lines = """ +# my_other_environment +# """ +# config_lines = """ +# my_extra_top_level_tox_configuration_lines +# """ +## [testenv] skip_install = true - -extras = - develop - test - +allowlist_externals = + echo + false +# Make sure typos like `tox -e formaat` are caught instead of silently doing nothing. +# See https://github.com/tox-dev/tox/issues/2858. commands = - {envbindir}/buildout -q -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap -# {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate - {envbindir}/buildout -n -qq -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test - coverage run {envbindir}/test -v1 --auto-color {posargs} + echo "Unrecognized environment name {envname}" + false + +## +# Add extra configuration options in .meta.toml: +# [tox] +# testenv_options = """ +# basepython = /usr/bin/python3.8 +# """ +## + +[testenv:init] +description = Prepare environment +skip_install = true +commands = + echo "Initial setup complete" -setenv = - COVERAGE_FILE=.coverage.{envname} - # version_file=test_plone60.cfg - Plone52: version_file=test_plone52.cfg - Plone60: version_file=test_plone60.cfg +[testenv:format] +description = automatically reformat code +skip_install = true deps = - Plone52: -rrequirements_plone52.txt -# Plone52: -cconstraints_plone52.txt - Plone60: -rrequirements_plone60.txt -# Plone60: -cconstraints_plone60.txt - coverage + pre-commit +commands = + pre-commit run -a pyupgrade + pre-commit run -a isort + pre-commit run -a black + pre-commit run -a zpretty +[testenv:lint] +description = run linters that will help improve the code style +skip_install = true +deps = + pre-commit +commands = + pre-commit run -a -[testenv:coverage-report] +[testenv:dependencies] +description = check if the package defines all its dependencies skip_install = true -usedevelop = True -basepython = python3.9 +deps = + build + z3c.dependencychecker==2.14.3 +commands = + python -m build --sdist + dependencychecker + +[testenv:dependencies-graph] +description = generate a graph out of the dependencies of the package +skip_install = false +allowlist_externals = + sh +deps = + pipdeptree==2.5.1 + graphviz # optional dependency of pipdeptree +commands = + sh -c 'pipdeptree --exclude setuptools,wheel,pipdeptree,zope.interface,zope.component --graph-output svg > dependencies.svg' + +[testenv:test] +description = run the distribution tests +use_develop = true +skip_install = false +constrain_package_deps = true +set_env = + ROBOT_BROWSER=headlesschrome + +## +# Specify extra test environment variables in .meta.toml: +# [tox] +# test_environment_variables = """ +# PIP_EXTRA_INDEX_URL=https://my-pypi.my-server.com/ +# """ +# +# Set constrain_package_deps .meta.toml: +# [tox] +# constrain_package_deps = "false" +## +deps = + zope.testrunner + -c https://dist.plone.org/release/6.0-dev/constraints.txt + +## +# Specify additional deps in .meta.toml: +# [tox] +# test_deps_additional = "-esources/plonegovbr.portal_base[test]" +# +# Specify a custom constraints file in .meta.toml: +# [tox] +# constraints_file = "https://my-server.com/constraints.txt" +## +commands = + zope-testrunner --all --test-path={toxinidir}/src -s collective.pdbpp {posargs} +extras = + test +## +# Add extra configuration options in .meta.toml: +# [tox] +# test_extras = """ +# tests +# widgets +# """ +## + +[testenv:coverage] +description = get a test coverage report +use_develop = true +skip_install = false +constrain_package_deps = true +set_env = + ROBOT_BROWSER=headlesschrome + +## +# Specify extra test environment variables in .meta.toml: +# [tox] +# test_environment_variables = """ +# PIP_EXTRA_INDEX_URL=https://my-pypi.my-server.com/ +# """ +## deps = coverage - -cconstraints_plone60.txt - -setenv = - COVERAGE_FILE=.coverage + zope.testrunner + -c https://dist.plone.org/release/6.0-dev/constraints.txt commands = - coverage erase - coverage combine - coverage html + coverage run --branch --source collective.pdbpp {envbindir}/zope-testrunner --quiet --all --test-path={toxinidir}/src -s collective.pdbpp {posargs} + coverage report -m --format markdown coverage xml - coverage report + coverage html +extras = + test + -[testenv:docs] +[testenv:release-check] +description = ensure that the distribution is ready to release skip_install = true +deps = + twine + build + -c https://dist.plone.org/release/6.0-dev/constraints.txt +commands = + python -m build --sdist + twine check dist/* + +[testenv:circular] +description = ensure there are no cyclic dependencies +use_develop = true +skip_install = false +# Here we must always constrain the package deps to what is already installed, +# otherwise we simply get the latest from PyPI, which may not work. +constrain_package_deps = true +set_env = + +## +# Specify extra test environment variables in .meta.toml: +# [tox] +# test_environment_variables = """ +# PIP_EXTRA_INDEX_URL=https://my-pypi.my-server.com/ +# """ +## +allowlist_externals = + sh deps = - Sphinx + pipdeptree + pipforester + -c https://dist.plone.org/release/6.0-dev/constraints.txt commands = - sphinx-build -b html -d _build/docs/doctrees docs _build/docs/html + # Generate the full dependency tree + sh -c 'pipdeptree -j > forest.json' + # Generate a DOT graph with the circular dependencies, if any + pipforester -i forest.json -o forest.dot --cycles + # Report if there are any circular dependencies, i.e. error if there are any + pipforester -i forest.json --check-cycles -o /dev/null + + +## +# Add extra configuration options in .meta.toml: +# [tox] +# extra_lines = """ +# _your own configuration lines_ +# """ +##