From 6b33fd9d202cd410f8733cb6f34e037e93fb026c Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Thu, 26 Jan 2023 11:33:38 +0100 Subject: [PATCH] Configuring with plone/meta --- .editorconfig | 39 +++++++++++++++++++++++++++++++++++ .github/workflows/linting.yml | 39 +++++++++++++++++++++++++++++++++++ lint-requirements.txt | 8 +++++++ pyproject.toml | 23 +++++++++++++++++++++ setup.cfg | 39 +++++++++++++++-------------------- tox.ini | 39 +++++++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+), 22 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/linting.yml create mode 100644 lint-requirements.txt create mode 100644 tox.ini diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b4158b8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +# +# EditorConfig Configuration file, for more details see: +# http://EditorConfig.org +# EditorConfig is a convention description, that could be interpreted +# by multiple editors to enforce common coding conventions for specific +# file types + +# top-most EditorConfig file: +# Will ignore other EditorConfig files in Home directory or upper tree level. +root = true + + +[*] # For All Files +# Unix-style newlines with a newline ending every file +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +# Set default charset +charset = utf-8 +# Indent style default +indent_style = space +# Max Line Length - a hard line wrap, should be disabled +max_line_length = off + +[*.{py,cfg,ini}] +# 4 space indentation +indent_size = 4 + +[*.{yml,zpt,pt,dtml,zcml}] +# 2 space indentation +indent_size = 2 + +[{Makefile,.gitmodules}] +# Tab indentation (no size specified, but view as 4 spaces) +indent_style = tab +indent_size = unset +tab_width = unset diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..a2139a8 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,39 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +name: Linting +on: + push: + branches: [master] + pull_request: + branches: [master] + workflow_dispatch: + +jobs: + test: + name: Lint code + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ["3.8"] + os: ["ubuntu-22.04"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Cache packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('lint-requirements.txt', 'tox.ini') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + ${{ runner.os }}-pip- + - name: Install dependencies + run: python -m pip install tox + - name: Run formatters + run: tox -e format + # linters + - name: QA + run: tox -e lint diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000..129db4d --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,8 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +black==22.12.0 +check-manifest==0.49 +codespell==2.2.2 +flake8==6.0.0 +isort==5.11.4 +pyupgrade==3.3.1 diff --git a/pyproject.toml b/pyproject.toml index 05b615d..0f96c85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,5 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default [tool.towncrier] filename = "CHANGES.rst" directory = "news/" @@ -18,3 +20,24 @@ showcontent = true directory = "bugfix" name = "Bug fixes:" showcontent = true + +[[tool.towncrier.type]] +directory = "internal" +name = "Internal:" +showcontent = true + +[[tool.towncrier.type]] +directory = "documentation" +name = "Documentation:" +showcontent = true + +[[tool.towncrier.type]] +directory = "tests" +name = "Tests" +showcontent = true + +[tool.isort] +profile = "plone" + +[tool.black] +target-version = ["py38"] diff --git a/setup.cfg b/setup.cfg index 3958a6a..3551aed 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,32 +1,27 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default [metadata] long_description = file: README.rst, CHANGES.rst -[check-manifest] -ignore = - *.txt - *.cfg - [bdist_wheel] universal = 0 -[isort] -profile = black -force_alphabetical_sort=True -force_single_line=True -lines_after_imports=2 - [flake8] -# black compatible flake8 rules: +doctests = 1 ignore = + # black takes care of line length + E501, + # black takes care of where to break lines W503, - C812, - E501 - T001 - C813 -# E203, E266 -exclude = bootstrap.py,docs,*.egg.,omelette -max-line-length = 88 -max-complexity = 18 -select = B,C,E,F,W,T4,B9 + # black takes care of spaces within slicing (list[:]) + E203, + # black takes care of spaces after commas + E231, -builtins = unicode,basestring +[check-manifest] +ignore = + .editorconfig + .meta.toml + tox.ini + *.txt + *.cfg diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..5d1a605 --- /dev/null +++ b/tox.ini @@ -0,0 +1,39 @@ +# Generated from: +# https://github.com/plone/meta/tree/master/config/default +[tox] +envlist = + format + lint + +[testenv] +py_files = git ls-files "*.py" +text_files = git ls-files "*.rst" "*.md" +allowlist_externals = + sh + +[testenv:format] +description = automatically reformat python code +skip_install = true +deps = + pyupgrade + isort + black + -c lint-requirements.txt +commands = + sh -c '{[testenv]py_files} | xargs pyupgrade --py38-plus' + sh -c '{[testenv]py_files} | xargs isort' + sh -c '{[testenv]py_files} | xargs black' + +[testenv:lint] +description = run linters that will help improve the code style +skip_install = true +deps = + flake8 + codespell + check-manifest + -c lint-requirements.txt +commands = + sh -c '{[testenv]py_files} | xargs flake8' + sh -c '{[testenv]py_files} | xargs codespell' + sh -c '{[testenv]text_files} | xargs codespell' + check-manifest