diff --git a/.github/workflows/lint_test.yml b/.github/workflows/lint_test.yml new file mode 100644 index 0000000..074ce0a --- /dev/null +++ b/.github/workflows/lint_test.yml @@ -0,0 +1,15 @@ +on: + pull_request: + push: + branches: + - main + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: pre-commit/action@v2.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4d57437 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +repos: + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.9 + hooks: + - id: flake8 + - repo: https://github.com/pycqa/isort + rev: 5.5.4 + hooks: + - id: isort + args: ["--profile", "black"] + - repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + language_version: python3 diff --git a/README.md b/README.md index 1490a44..0f8b661 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,6 @@ If you like the project, here's a few things you can do - Open issues, participate on discussions, report bugs, suggest ideas - Star the project - Add functionality, work on a PR, fix an issue! - +- Before you send a PR, make sure your code is properly formatted. For that, use `pre-commit install` to install a pre-commit hook and run `pre-commit run --all` and fix everything before you commit. This pre-commit will check for your code lint everytime you commit a code. ## Contact info@mediacms.io diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..496288f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[tool.black] +line-length = 200 +target-version = ['py36', 'py37', 'py38'] +skip-string-normalization = true +include = '\.pyi?$' +exclude = ''' +/( + \.* + | \.git + | \.mypy_cache + | \.venv + # The following are specific to Black, you probably don't want those. + | blib2to3 + | tests/data + | profiling +)/ +''' diff --git a/requirements.txt b/requirements.txt index e2fa470..8eeedec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,3 +32,4 @@ flake8 pep8 django-silk django-debug-toolbar +pre-commit diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..30335b4 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,4 @@ +[flake8] +exclude = .git,*migrations* +max-line-length = 119 +ignore=F401,E711,E302,E201,E501,E303,E231,F841,E722