Skip to content

Read options from configuration #5

@mauritsvanrees

Description

@mauritsvanrees

We currently need something like this in for example a Makefile:

PACKAGE_PATH=plone/
CHECK_PATH=setup.py $(PACKAGE_PATH)
LINT=docker run --rm -v "$(PWD)":/github/workspace plone/code-quality:1.0.1 check
lint:
	# Would be nice to have a way to run all available checks, instead of specifying them here.
	$(LINT) isort "$(CHECK_PATH)"
	$(LINT) black "$(CHECK_PATH)"
	$(LINT) flake8 "$(CHECK_PATH)"
	$(LINT) pyroma .
	$(LINT) zpretty "$(PACKAGE_PATH)"

And then in .github/workflows/code-analysis.yml you pass the same kinds of options/paths to the commands.
It would be nice if we can add some configuration in pyproject.toml and read it in docker-entrypoint.py:

import tomli
tomli.load(open("pyproject.toml", "rb"))

Configuration could be this:

[tool.plone.code-quality]
package_path = "plone/"
check_path= "setup.py plone"
# If no formatter or checker is given on the command line, run these:
formatters = ["isort", "black"]
checkers = ["black", "flake8"]

and/or this:

[tool.plone.code-quality.plugins]
isort = "setup.py plone"
# a list could work too:
black = ["setup.py", "plone"]
# disable this check:
flake8 = false
# this should be the default:
pyroma = "."
zpretty = "plone"

Result is like this:

{'tool': {'plone': {'code-quality': {
                                     'check_path': 'setup.py plone',
                                     'package_path': 'plone/',
                                     'checkers': ['black', 'flake8'],
                                     'formatters': ['isort', 'black'],
                                     'plugins': {'black': ['setup.py', 'plone'],
                                                 'flake8': False,
                                                 'isort': 'setup.py plone',
                                                 'pyroma': '.',
                                                 'zpretty': 'plone'}}}}}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions