From 16a46504fc359114df7f6854b0dee3940df38b04 Mon Sep 17 00:00:00 2001 From: Antoni Segura Puimedon Date: Sep 27 2018 11:09:39 +0000 Subject: Add optional black git pre-commit hook Since Pagure uses black for its code formatting, it makes sense to have optional support for running it as a pre-commit hook for those days when you forget to run it before making a pull request. --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d1db311 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black + language_version: python3.6 diff --git a/doc/contributing.rst b/doc/contributing.rst index bd54af5..db88ae8 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -10,7 +10,12 @@ If you're submitting patches to pagure, please observe the following: - We run the source code through `black `_ as part of the tests, so you may have to do some adjustments or run it - yourself (which is simple: ``black /path/to/pagure``). + yourself (which is simple: ``black /path/to/pagure``). Instead, you can just + install `pre-commit `_ then run:: + + pre-commit install + This will make that each time you commit, black is run automatically on the + change. - Check that your code doesn't break the test suite. The test suite can be run using the ``runtests.sh`` shell script at the top of the sources. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..81173ae --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.black] +line-length = 79 +py36 = true +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | dev + | doc + | fedmsg.d + | files +)/ +'''