Merge pull request 'feat: pre-commit' (#1) from feat-pre-commit into django-fastapi
Reviewed-on: #1
This commit is contained in:
commit
9d14ac88e5
87
.dockerignore
Normal file
87
.dockerignore
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
|
||||||
|
# CI
|
||||||
|
.codeclimate.yml
|
||||||
|
.travis.yml
|
||||||
|
.taskcluster.yml
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
docker-compose.yml
|
||||||
|
Dockerfile
|
||||||
|
.docker
|
||||||
|
.dockerignore
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
**/__pycache__/
|
||||||
|
**/*.py[cod]
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Python mode for VIM
|
||||||
|
.ropeproject
|
||||||
|
**/.ropeproject
|
||||||
|
|
||||||
|
# Vim swap files
|
||||||
|
**/*.swp
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
.flake8
|
||||||
|
.pre-commit-config.yaml
|
5
.flake8
Normal file
5
.flake8
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[flake8]
|
||||||
|
ignore = E203, E266, E501, W503, F403, F401, E402
|
||||||
|
max-line-length = 119
|
||||||
|
max-complexity = 18
|
||||||
|
select = B,C,E,F,W,T4,B9
|
32
.pre-commit-config.yaml
Normal file
32
.pre-commit-config.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.6.0
|
||||||
|
hooks:
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- repo: https://github.com/PyCQA/autoflake
|
||||||
|
rev: v2.3.1
|
||||||
|
hooks:
|
||||||
|
- id: autoflake
|
||||||
|
args:
|
||||||
|
- "--in-place"
|
||||||
|
- "--remove-duplicate-keys"
|
||||||
|
- "--remove-unused-variables"
|
||||||
|
- "--remove-all-unused-imports"
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
|
rev: v5.10.1
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
args: ["--profile", "black"]
|
||||||
|
- repo: https://github.com/ambv/black
|
||||||
|
rev: 24.4.2
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
args:
|
||||||
|
- "--line-length=119"
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 7.1.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
|
||||||
|
default_language_version:
|
||||||
|
python: python3.12
|
25
README.md
25
README.md
@ -1,13 +1,36 @@
|
|||||||
# simpliest django(uvicorn)+postgresql+fastapi+redis+nginx docker-compose (ready for production and dev)
|
# simpliest django(uvicorn)+postgresql+fastapi+redis+nginx docker-compose (ready for production and dev)
|
||||||
|
## How to use
|
||||||
To run:
|
To run:
|
||||||
`docker-compose up -d`
|
`docker-compose up -d`
|
||||||
|
|
||||||
Site available on 8000 port.
|
Site available on 8000 port.
|
||||||
|
|
||||||
You can make any changes in code, they will appear automatically. If you want to execute something with manage.py use:
|
You can make any changes in code, they will appear automatically. If you want to execute something with manage.py use:
|
||||||
```
|
```sh
|
||||||
docker-compose exec app python3 manage.py migrate
|
docker-compose exec app python3 manage.py migrate
|
||||||
docker-compose exec app python3 manage.py makemigrations
|
docker-compose exec app python3 manage.py makemigrations
|
||||||
docker-compose exec app python3 manage.py update_admin admin adminpass # create superuser
|
docker-compose exec app python3 manage.py update_admin admin adminpass # create superuser
|
||||||
```
|
```
|
||||||
and so on.
|
and so on.
|
||||||
|
|
||||||
|
## Install formatting
|
||||||
|
**Features**
|
||||||
|
- check for unsolved merge conflicts
|
||||||
|
- black formatting
|
||||||
|
- sort imports
|
||||||
|
- remove unused variables, imports, duplicates
|
||||||
|
- flake8 verification
|
||||||
|
|
||||||
|
It executes on **every** commit
|
||||||
|
```sh
|
||||||
|
pip install pre-commit flake8 black
|
||||||
|
pre-commit install
|
||||||
|
```
|
||||||
|
Apply for all files in current directory:
|
||||||
|
```sh
|
||||||
|
pre-commit run --all-files
|
||||||
|
```
|
||||||
|
If there is PEP8 errors, commit will be forbidden. To force commit use flag --no-verify:
|
||||||
|
```sh
|
||||||
|
git commit --no-verify ...
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user