Add pre-commit
This commit is contained in:
20
.pre-commit-config.yaml
Normal file
20
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v3.2.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude: README.md
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 23.1.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
- repo: https://github.com/timothycrosley/isort
|
||||||
|
rev: 5.12.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
- repo: https://github.com/pycqa/flake8
|
||||||
|
rev: 6.0.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
20
README.md
20
README.md
@@ -150,3 +150,23 @@ poetry shell
|
|||||||
source .env
|
source .env
|
||||||
python -m app.main
|
python -m app.main
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Linting
|
||||||
|
|
||||||
|
This project uses multiple linting plugins to ensure code formatting is consistent.
|
||||||
|
|
||||||
|
1. `black .` is opinionated but uncompromising code formatting.
|
||||||
|
2. `flake8` enforces style guide, i.E. PEP8.
|
||||||
|
3. `isort .` sorts imports.
|
||||||
|
|
||||||
|
Additionally, there is a pre-commit hook you can install to fix trailing whitespace, end of file and some yaml issues.
|
||||||
|
```bash
|
||||||
|
pre-commit install
|
||||||
|
```
|
||||||
|
|
||||||
|
You may also use it to quickly check through everything without needing to commit:
|
||||||
|
```bash
|
||||||
|
pre-commit run --all-files
|
||||||
|
```
|
||||||
|
|
||||||
|
Depending on your shell compatibility with poetry, you may have to prefix all of the above commands with `poetry run`.
|
||||||
|
|||||||
99
poetry.lock
generated
99
poetry.lock
generated
@@ -43,6 +43,14 @@ category = "main"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfgv"
|
||||||
|
version = "3.3.1"
|
||||||
|
description = "Validate configuration and produce human readable error messages."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "charset-normalizer"
|
name = "charset-normalizer"
|
||||||
version = "3.0.1"
|
version = "3.0.1"
|
||||||
@@ -81,6 +89,26 @@ python-versions = ">=3.7"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
toml = ["tomli"]
|
toml = ["tomli"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "distlib"
|
||||||
|
version = "0.3.6"
|
||||||
|
description = "Distribution utilities"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "filelock"
|
||||||
|
version = "3.9.0"
|
||||||
|
description = "A platform independent file lock."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo (>=2022.12.7)", "sphinx-autodoc-typehints (>=1.19.5)", "sphinx (>=5.3)"]
|
||||||
|
testing = ["covdefaults (>=2.2.2)", "coverage (>=7.0.1)", "pytest-cov (>=4)", "pytest-timeout (>=2.1)", "pytest (>=7.2)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flake8"
|
name = "flake8"
|
||||||
version = "6.0.0"
|
version = "6.0.0"
|
||||||
@@ -94,6 +122,17 @@ mccabe = ">=0.7.0,<0.8.0"
|
|||||||
pycodestyle = ">=2.10.0,<2.11.0"
|
pycodestyle = ">=2.10.0,<2.11.0"
|
||||||
pyflakes = ">=3.0.0,<3.1.0"
|
pyflakes = ">=3.0.0,<3.1.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "identify"
|
||||||
|
version = "2.5.20"
|
||||||
|
description = "File identification library for Python"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
license = ["ukkonen"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "3.4"
|
version = "3.4"
|
||||||
@@ -155,6 +194,14 @@ category = "dev"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.5"
|
python-versions = ">=3.5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nodeenv"
|
||||||
|
version = "1.7.0"
|
||||||
|
description = "Node.js virtual environment builder"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "packaging"
|
name = "packaging"
|
||||||
version = "23.0"
|
version = "23.0"
|
||||||
@@ -175,7 +222,7 @@ python-versions = ">=3.7"
|
|||||||
name = "platformdirs"
|
name = "platformdirs"
|
||||||
version = "3.1.0"
|
version = "3.1.0"
|
||||||
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||||
category = "dev"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
@@ -195,6 +242,21 @@ python-versions = ">=3.6"
|
|||||||
dev = ["pre-commit", "tox"]
|
dev = ["pre-commit", "tox"]
|
||||||
testing = ["pytest", "pytest-benchmark"]
|
testing = ["pytest", "pytest-benchmark"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pre-commit"
|
||||||
|
version = "3.1.1"
|
||||||
|
description = "A framework for managing and maintaining multi-language pre-commit hooks."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
cfgv = ">=2.0.0"
|
||||||
|
identify = ">=1.0.0"
|
||||||
|
nodeenv = ">=0.11.1"
|
||||||
|
pyyaml = ">=5.1"
|
||||||
|
virtualenv = ">=20.10.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pycodestyle"
|
name = "pycodestyle"
|
||||||
version = "2.10.0"
|
version = "2.10.0"
|
||||||
@@ -244,6 +306,14 @@ pytest = ">=4.6"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"]
|
testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyyaml"
|
||||||
|
version = "6.0"
|
||||||
|
description = "YAML parser and emitter for Python"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
version = "2.28.2"
|
version = "2.28.2"
|
||||||
@@ -299,6 +369,23 @@ brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"]
|
|||||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "urllib3-secure-extra", "ipaddress"]
|
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "urllib3-secure-extra", "ipaddress"]
|
||||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "virtualenv"
|
||||||
|
version = "20.20.0"
|
||||||
|
description = "Virtual Python Environment builder"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
distlib = ">=0.3.6,<1"
|
||||||
|
filelock = ">=3.4.1,<4"
|
||||||
|
platformdirs = ">=2.4,<4"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx-argparse (>=0.4)", "sphinx (>=6.1.3)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=22.12)"]
|
||||||
|
test = ["covdefaults (>=2.2.2)", "coverage-enable-subprocess (>=1)", "coverage (>=7.1)", "flaky (>=3.7)", "packaging (>=23)", "pytest-env (>=0.8.1)", "pytest-freezegun (>=0.4.2)", "pytest-mock (>=3.10)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "pytest (>=7.2.1)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "win32-setctime"
|
name = "win32-setctime"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -313,12 +400,13 @@ dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.11"
|
python-versions = "^3.11"
|
||||||
content-hash = "49398c01804a5f064b961089ffcdf2764ee95e2dd8bb35ece7bac34eec617534"
|
content-hash = "214ba051cbd09df53ac7c0fcce560c9617314f3d26ab703df34f31169bd63eb3"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
attrs = []
|
attrs = []
|
||||||
black = []
|
black = []
|
||||||
certifi = []
|
certifi = []
|
||||||
|
cfgv = []
|
||||||
charset-normalizer = []
|
charset-normalizer = []
|
||||||
click = [
|
click = [
|
||||||
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
|
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
|
||||||
@@ -326,23 +414,30 @@ click = [
|
|||||||
]
|
]
|
||||||
colorama = []
|
colorama = []
|
||||||
coverage = []
|
coverage = []
|
||||||
|
distlib = []
|
||||||
|
filelock = []
|
||||||
flake8 = []
|
flake8 = []
|
||||||
|
identify = []
|
||||||
idna = []
|
idna = []
|
||||||
iniconfig = []
|
iniconfig = []
|
||||||
isort = []
|
isort = []
|
||||||
loguru = []
|
loguru = []
|
||||||
mccabe = []
|
mccabe = []
|
||||||
mypy-extensions = []
|
mypy-extensions = []
|
||||||
|
nodeenv = []
|
||||||
packaging = []
|
packaging = []
|
||||||
pathspec = []
|
pathspec = []
|
||||||
platformdirs = []
|
platformdirs = []
|
||||||
pluggy = []
|
pluggy = []
|
||||||
|
pre-commit = []
|
||||||
pycodestyle = []
|
pycodestyle = []
|
||||||
pyflakes = []
|
pyflakes = []
|
||||||
pytest = []
|
pytest = []
|
||||||
pytest-cov = []
|
pytest-cov = []
|
||||||
|
pyyaml = []
|
||||||
requests = []
|
requests = []
|
||||||
requests-mock = []
|
requests-mock = []
|
||||||
six = []
|
six = []
|
||||||
urllib3 = []
|
urllib3 = []
|
||||||
|
virtualenv = []
|
||||||
win32-setctime = []
|
win32-setctime = []
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ authors = ["Deko <gadse.deko@gmail.com>"]
|
|||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
requests = "^2.28.2"
|
requests = "^2.28.2"
|
||||||
loguru = "^0.6.0"
|
loguru = "^0.6.0"
|
||||||
|
pre-commit = "^3.1.1"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
black = "^23.1.0"
|
black = "^23.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user