poetry-black.yml is a reusable GitHub workflow for the Black code formatter for Python.
Create a new workflow file in all repositories whose files should get formatted with Black.
The following example config runs Black on all pull requests:
name: Run Black code formatter
on: pull_request
jobs:
poetry-black:
uses: acdh-oeaw/prosnet-workflows/.github/workflows/poetry-black.yml@RELEASE_VERSION
with:
src: "."
RELEASE_VERSION
needs to be set to a valid prosnet-workflows release tag, branch name or SHA.src
refers to the path from which Black will work its way down the hierarchical file structure. The example uses"."
, the current working directory, which may serve you best. Only change it if you need Black to start from a different directory instead.
The following optional variables can be added to the with
section of the config:
python-version
: The Python version for which to set up Poetry, which is used to run Black. For APIS projects, the prosnet-workflows default should work best.options
: Arguments with which to runpoetry run black
, see Black command line options. If you set this variable, it will override the prosnet-workflows defaults.