From d5fb11eccb4387712134e544b784ab0230670c9c Mon Sep 17 00:00:00 2001 From: LukasMoll <86722560+LukasMoll@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:18:55 +0200 Subject: [PATCH] Python pre-commit pipeline to enforce best practices. (#8181) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ãmade config files for black and flake8 pre-commit pipeline * added documentation for pre-commit pipeline * Mitigates tag change error * removed black version in pre commit config * Add E711 to the list of ignored flake8 errors See #330 Co-authored-by: Lukas Molleman Co-authored-by: Andrew Noyes --- .flake8 | 5 +++++ .pre-commit-config.yaml | 9 +++++++++ CONTRIBUTING.md | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 .flake8 create mode 100644 .pre-commit-config.yaml diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..c72f249028 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +ignore = E203, E266, E501, W503, F403, F401, E711 +max-line-length = 79 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..a843a71aac --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: +- repo: https://github.com/psf/black + rev: 2018e667a6a36ee3fbfa8041cd36512f92f60d49 # frozen: 22.8.0 + hooks: + - id: black +- repo: https://github.com/pycqa/flake8 + rev: f8e1b317742036ff11ff86356fd2b68147e169f7 # frozen: 5.0.4 + hooks: + - id: flake8 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35845dbb08..f142b3dfae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,9 @@ We love pull requests! For minor changes, feel free to open up a PR directly. Fo CI will be run automatically for core committers, and for community PRs it will be initiated by the request of a core committer. Tests can also be run locally via `ctest`, and core committers can run additional validation on pull requests prior to merging them. +### Python pre-commit +We use a pre-commit pipeline with black and flake8 to enforce python best coding practices. Install pre-commit ```pip install pre-commit```. Install it in your FoundationDB directory ```pre-commit install```. + ### Reporting issues Please refer to the section below on [using GitHub issues and the community forums](#using-github-issues-and-community-forums) for more info.