From c28c307670d08d59907c7e1b705f4b86f034bdcb Mon Sep 17 00:00:00 2001 From: Ivan Golikov Date: Sun, 12 Jun 2022 15:33:14 +0300 Subject: [PATCH 1/3] Run Black + Flake8 + isort before commit automatically --- .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ pyproject.toml | 7 +++++++ setup.cfg | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8a118a5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +repos: + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + language_version: python3.10 + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + entry: pflake8 + additional_dependencies: + - flake8-bugbear + - flake8-comprehensions + - flake8-simplify + - pyproject-flake8 + + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + name: isort diff --git a/pyproject.toml b/pyproject.toml index b0f0765..869016d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,10 @@ [build-system] requires = ["setuptools>=42"] build-backend = "setuptools.build_meta" + +[tool.isort] +profile = "black" + +[tool.flake8] +max-line-length = 88 +extend-ignore = "E203, B008" diff --git a/setup.cfg b/setup.cfg index c2a9345..384c067 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,6 +13,8 @@ python_requires = >=3.10 [options.extras_require] hiredis = hiredis==2.0.0 +development = + pre-commit==2.19.0 [options.packages.find] where = src From faa6bd8beb87071a8e2726d78b778651796036a2 Mon Sep 17 00:00:00 2001 From: Ivan Golikov Date: Sun, 12 Jun 2022 15:44:27 +0300 Subject: [PATCH 2/3] Added Contributing section to README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 8fce708..8f8413a 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,18 @@ This service tries to be as anonymous as possible. The only personal information on a server will be IP address of the client that made request to the server. Service is built with Python, FastAPI and is using Redis for data storage. + +## Contributing + +Codestyle is enforced with Black, and additional checks are done with the help of pre-commit-hooks, +Flake8 and isort. Prior to making any commits, install `pre-commit` tool and install hooks: + +``` +# Alternatively, you could use 'pip install ".[development]"' +$ pip install pre-commit==2.19.0 +$ pre-commit install +``` + +This way you will always be sure that new code follows project guidelines. + +This project is using trunk-based branching strategy with the `main` as trunk branch. From d8dc37e79bcd5fa5565b58745eb3681abd6fbe31 Mon Sep 17 00:00:00 2001 From: Ivan Golikov Date: Sun, 12 Jun 2022 15:45:42 +0300 Subject: [PATCH 3/3] Added Black badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8f8413a..3b13b1c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Rectes +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) + Rectes (anagram from "secret") is self-hosted service to share secrets (like passwords) with somebody over the network, but don't want them to appear in chats, unencrypted e-mails, etc.