Skip to content

Commit

Permalink
added linting configs
Browse files Browse the repository at this point in the history
  • Loading branch information
hemant10yadav committed Jan 6, 2025
1 parent 272a9d7 commit efb12b9
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ concurrency:
cancel-in-progress: true

jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Run pre-commit
uses: pre-commit/[email protected]

pytest:
runs-on: ubuntu-latest

Expand Down
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
default_stages: [pre-commit]


repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
args: ['--tab-width', '2', '--single-quote']
exclude: 'templates/'

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.13.0'
hooks:
- id: django-upgrade
args: ['--target-version', '4.1']

- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py311-plus]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,50 @@ python_files = [
"tests.py",
"test_*.py",
]

# ==== black ====
[tool.black]
line-length = 119
target-version = ['py311']


# ==== isort ====
[tool.isort]
profile = "black"
line_length = 119
known_first_party = [
"commcare_connect",
"config",
]
skip = ["venv/"]
skip_glob = ["**/migrations/*.py"]

# ==== PyLint ====
[tool.pylint.MASTER]
load-plugins = [
"pylint_django",
"pylint_celery",
]
django-settings-module = "config.settings.local"

[tool.pylint.FORMAT]
max-line-length = 119

[tool.pylint."MESSAGES CONTROL"]
disable = [
"missing-docstring",
"invalid-name",
]

[tool.pylint.DESIGN]
max-parents = 13

[tool.pylint.TYPECHECK]
generated-members = [
"REQUEST",
"acl_users",
"aq_parent",
"[a-zA-Z]+_set{1,2}",
"save",
"delete",
]
4 changes: 4 additions & 0 deletions requirements/requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ pip-tools
pytest
pytest-django
factory-boy
flake8
flake8-isort
black
pre-commit
42 changes: 42 additions & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,64 @@
#
# pip-compile requirements/requirements-dev.in
#
black==24.10.0
# via -r requirements/requirements-dev.in
build==0.10.0
# via pip-tools
cfgv==3.4.0
# via pre-commit
click==8.1.3
# via
# -c requirements/requirements.txt
# black
# pip-tools
distlib==0.3.9
# via virtualenv
factory-boy==3.3.0
# via -r requirements/requirements-dev.in
faker==19.6.2
# via factory-boy
filelock==3.16.1
# via virtualenv
flake8==7.1.1
# via
# -r requirements/requirements-dev.in
# flake8-isort
flake8-isort==6.1.1
# via -r requirements/requirements-dev.in
identify==2.6.5
# via pre-commit
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via flake8-isort
mccabe==0.7.0
# via flake8
mypy-extensions==1.0.0
# via black
nodeenv==1.9.1
# via pre-commit
packaging==23.1
# via
# black
# build
# pytest
pathspec==0.12.1
# via black
pip-tools==6.13.0
# via -r requirements/requirements-dev.in
platformdirs==4.3.6
# via
# black
# virtualenv
pluggy==1.3.0
# via pytest
pre-commit==4.0.1
# via -r requirements/requirements-dev.in
pycodestyle==2.12.1
# via flake8
pyflakes==3.2.0
# via flake8
pyproject-hooks==1.0.0
# via build
pytest==7.4.2
Expand All @@ -36,10 +74,14 @@ python-dateutil==2.9.0.post0
# via
# -c requirements/requirements.txt
# faker
pyyaml==6.0.2
# via pre-commit
six==1.16.0
# via
# -c requirements/requirements.txt
# python-dateutil
virtualenv==20.28.1
# via pre-commit
wheel==0.40.0
# via pip-tools

Expand Down
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# flake8 and pycodestyle don't support pyproject.toml
# https://github.com/PyCQA/flake8/issues/234
# https://github.com/PyCQA/pycodestyle/issues/813
[flake8]
max-line-length = 119
exclude = .git,*/migrations/*,venv,.venv

[pycodestyle]
max-line-length = 119
exclude = .git,*/migrations/*,venv,.venv

0 comments on commit efb12b9

Please sign in to comment.