Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev tools #190

Open
wants to merge 6 commits into
base: upgrade-django-and-python-versions
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .coveragerc

This file was deleted.

3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

41 changes: 18 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
exclude: 'docs|node_modules|migrations|.git|.tox'
exclude: |
^(venv|env|\.tox|django_drip_campaigns\.egg-info|__pycache__|docs|legacy_docs|.*/migrations/.*\.py)$
default_stages: [commit]
fail_fast: true
default_language_version:
python: python3.8
python: python3.12

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

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

- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--settings-path=setup.cfg"]

- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
args: ['--config=setup.cfg']
additional_dependencies: [flake8-isort]
args: ["--config=setup.cfg"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v1.11.2
hooks:
- id: mypy
args: ['--namespace-packages', '--explicit-package-bases', '--ignore-missing-imports', '--no-warn-unused-ignores']
additional_dependencies: [django-stubs, six, types-six]
args: ["--config-file=setup.cfg"]
additional_dependencies: [django-stubs, six]

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args: ["--config=pyproject.toml"]
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ with older versions of Python.
from the `test-requirements.txt` file that has the list of the needed dev libraries.
- You will see the tests execution for each version of Python.
- You can run `tox -v` to see more details.
8. Run `pre-commit install` so pre-commit is configured. This will make that some dev tools are run when making a git commit. The tools are
explained in the next section.

### Use of Dev tools

If you want to develop in Django Drip, you will need to use these dev tools:

- isort: to automatically sort imports in Python files, ensuring a consistent and organized format. Before the commit, run `isort .`, this will sort the imports.
- black: to automatically format Python code by enforcing a consistent style, improving readability while adhering to PEP 8 guidelines. Before the commit, run `black .`. This will format the files.
- flake8: to enforce coding style guidelines and check for code quality issues in Python, including PEP 8 compliance, syntax errors, and potential bugs. Before the commit, run `flake8 .`. This will show errors if any of the used guidelines are not being met.
- mypy: used for static type checking in Python, ensuring that variables, functions, and return types match the expected types specified in type hints. Before commit, run `mypy .`. This will show errors if there is any typing error.

All these tools are configured in the setup.cfg file, except black, that can't use that file and uses pyproject.toml.
It's important to make sure these four tools are executed successfuly before making any git commit. If any of them
shows any errors, you need to fix all of them before making the commit.

### Test Coverage

If you add new code, make sure you create tests for it and make sure you don't decrease the percentage of test coverage.

1. You can run: `coverage run -m pytest .`
2. Now run: `coverage report -m`

This way you will see a complete report of the tests. The percentage coverage should be equal or greater to the current one: 94%.

## Use a Consistent Coding Style

Expand Down
24 changes: 16 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "==4.2.16"
apscheduler = "==3.10.4"
celery = "==5.4.0"
django = "==4.2.16"
typing-extensions = "==4.12.2"

[dev-packages]
black = "==24.8.0"
coverage = "==7.6.1"
django-coverage-plugin = "==3.1.0"
django-stubs = "==5.1.0"
factory-boy = "==3.3.1"
faker = "==29.0.0"
flake8 = "==7.1.1"
isort = "==5.13.2"
mypy = "==1.11.2"
pytest = "==8.3.3"
pytest-sugar = "==1.0.0"
pytest-django = "==4.9.0"
pytest-celery = "==0.0.0"
faker = "==29.0.0"
factory-boy = "==3.3.1"
pytest-django = "==4.9.0"
pytest-sugar = "==1.0.0"
tox = "==4.20.0"
coverage = "==7.6.1"
types-six = "==1.16.21.20240513"
pre-commit = "==3.8.0"

[requires]
python_version = "3.12"
python_full_version = "3.12.4"
python_version = "3.12"
Loading