Created
October 10, 2022 01:14
-
-
Save jean-leonco/f2b13f239671a1c6b0893914fdfb2e1f to your computer and use it in GitHub Desktop.
Basic python setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[flake8] | |
max-line-length = 88 | |
extend-exclude = .venv | |
extend-ignore = | |
E203, # whitespace before ':' (conflicts with Black) | |
E231, # Bad trailing comma (conflicts with Black) | |
E501, # line too long (conflicts with Black) | |
W503, # line break before binary operator (conflicts with Black) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://pre-commit.com for more information | |
# See https://pre-commit.com/hooks.html for more hooks | |
repos: | |
- repo: https://github.com/pre-commit/pre-commit-hooks | |
rev: v3.2.0 | |
hooks: | |
- id: trailing-whitespace | |
- id: end-of-file-fixer | |
- id: check-toml | |
- id: check-yaml | |
exclude: ^helm/ | |
- id: check-added-large-files | |
- id: requirements-txt-fixer | |
args: ['requirements.in', 'requirements-dev.txt'] | |
- repo: https://github.com/psf/black | |
rev: 22.3.0 | |
hooks: | |
- id: black | |
- repo: https://github.com/timothycrosley/isort | |
rev: 5.10.1 | |
hooks: | |
- id: isort | |
# Reference https://github.com/psf/black/blob/main/.pre-commit-config.yaml#L34 | |
- repo: https://gitlab.com/pycqa/flake8 | |
rev: 4.0.1 | |
hooks: | |
- id: flake8 | |
# additional_dependencies: | |
# - flake8-bugbear | |
# - flake8-comprehensions | |
# - flake8-simplify | |
- repo: https://github.com/compilerla/conventional-pre-commit | |
rev: v1.2.0 | |
hooks: | |
- id: conventional-pre-commit | |
stages: [commit-msg] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3.7.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup application and install dependencies | |
setup: | |
pip install -U pip | |
pip install -r requirements-dev.txt | |
pip install -r requirements.txt | |
pre-commit install | |
# Setup application and install dependencies on CI mode | |
setup-ci: | |
pip install -U pip | |
pip install -r requirements-dev.txt | |
pip install -r requirements.txt | |
# Generate lock file for production dependencies | |
generate-requirements: | |
pip-compile --generate-hashes --output-file=requirements.txt requirements.in | |
# Run application tests | |
test: | |
pytest | |
# Run coverage for application tests | |
coverage: | |
coverage run -m pytest | |
coverage report -m | |
coverage xml | |
# Format code style | |
format: | |
black . | |
isort . | |
# Run lint | |
lint: | |
flake8 . --count --show-source --statistics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tool.black] | |
extend-exclude = ".git, __pycache__, .venv" | |
[tool.isort] | |
profile = "black" | |
skip_gitignore = true | |
multi_line_output = 3 | |
include_trailing_comma = true | |
force_grid_wrap = 0 | |
use_parentheses = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[pytest] | |
addopts = -r a --capture=no -vv --log-level=INFO --color=yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment