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/README.md b/README.md index 8fce708..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. @@ -7,3 +9,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. 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