diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5f752b1 --- /dev/null +++ b/.dockerignore @@ -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 \ No newline at end of file diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..92773e3 --- /dev/null +++ b/.flake8 @@ -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 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..36e8cf2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 189a948..de0c336 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # simpliest django(uvicorn)+postgresql+fastapi+redis+nginx docker-compose (ready for production and dev) - +## How to use To run: `docker-compose up -d` 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: - -``` +```sh docker-compose exec app python3 manage.py migrate docker-compose exec app python3 manage.py makemigrations docker-compose exec app python3 manage.py update_admin admin adminpass # create superuser @@ -20,3 +19,25 @@ Example task [task_example.py](src/application/tasks/task_example.py) Example register task [__init__.py](src/application/tasks/__init__.py) Example send task [send_task.py](src/application/management/commands/send_task.py) + +## 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 ... +```