diff --git a/.github/workflows/run_black_linter.yml b/.github/workflows/run_black_linter.yml
index 4b92ce19..f9bcd9b5 100644
--- a/.github/workflows/run_black_linter.yml
+++ b/.github/workflows/run_black_linter.yml
@@ -14,5 +14,5 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v4.1.6
- uses: psf/black@stable
diff --git a/.github/workflows/run_djlint.yml b/.github/workflows/run_djlint.yml
index 02b47210..0d7c02a8 100644
--- a/.github/workflows/run_djlint.yml
+++ b/.github/workflows/run_djlint.yml
@@ -11,24 +11,18 @@ on:
jobs:
lint:
- strategy:
- fail-fast: true
- matrix:
- os: [ "ubuntu-latest" ]
- python-version: [ "3.10", "3.11", "3.12" ]
- django-version: [ "4", "5" ]
- runs-on: ${{ matrix.os }}
+ runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
- uses: actions/checkout@v4
- - name: Set up python ${{ matrix.python-version }}
+ uses: actions/checkout@v4.1.6
+ - name: Set up python
id: setup-python
- uses: actions/setup-python@v5
+ uses: actions/setup-python@v5.1.0
with:
- python-version: ${{ matrix.python-version }}
+ python-version: "3.12"
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
@@ -42,7 +36,7 @@ jobs:
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4.0.2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
diff --git a/.github/workflows/run_mypy.yml b/.github/workflows/run_mypy.yml
new file mode 100644
index 00000000..286b4b68
--- /dev/null
+++ b/.github/workflows/run_mypy.yml
@@ -0,0 +1,47 @@
+name: Mypy
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+jobs:
+ mypy:
+ name: mypy
+ runs-on: ubuntu-latest
+ env:
+ SECRET_KEY: "some!random!secret!key!use!online!generator!to!get"
+ URL: "127.0.0.1"
+ PROXY_IP: "localhost"
+ BRANCH: "debug"
+ DEBUG: "true"
+ DATABASE_TYPE: "sqlite3"
+ SITE_URL: "http://myfinances.example.com"
+ SITE_NAME: "myfinances"
+ steps:
+ - name: Clone repo
+ uses: actions/checkout@v4.1.6
+ - name: Set up python
+ uses: actions/setup-python@v5.1.0
+ with:
+ python-version: "3.12"
+ - name: Install and configure Poetry
+ uses: snok/install-poetry@v1
+ with:
+ virtualenvs-create: true
+ virtualenvs-in-project: true
+ installer-parallel: true
+ - name: Load cached venv
+ id: cached-poetry-dependencies
+ uses: actions/cache@v4.0.2
+ with:
+ path: .venv
+ key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
+ - name: Install dependencies
+ if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+ run: poetry install --no-interaction --no-root
+ - name: Run mypy checks
+ run: |
+ source .venv/bin/activate
+ mypy .
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index f5448616..489d8118 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -16,7 +16,7 @@ jobs:
django-version: ["4", "5"]
steps:
- name: Clone repo
- uses: actions/checkout@v4.1.4
+ uses: actions/checkout@v4.1.6
- name: Set up python
uses: actions/setup-python@v5.1.0
with:
@@ -24,7 +24,6 @@ jobs:
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
- version: 1.8.0
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
@@ -79,4 +78,3 @@ jobs:
source .venv/bin/activate
python3 manage.py collectstatic --no-input
python3 manage.py test --parallel
-
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ffbc447c..27138d6f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -4,6 +4,10 @@ repos:
entry: black --check --diff
hooks:
- id: black
+ name: Black Formatter
+ files: .
+ language: python
+ types: [ python ]
- repo: local
hooks:
- id: pre-commit-django-migrations
@@ -11,28 +15,54 @@ repos:
entry: python manage.py makemigrations --dry-run --check --no-input
language: system
types: [ python ]
+ files: ./backend/models.py
pass_filenames: false
- repo: local
hooks:
- id: pre-commit-djlint
name: Djlint (html files)
- entry: djlint . --profile django --check
+ entry: djlint ./frontend/templates/ --profile django --reformat
language: system
- types: [ python ]
+ files: ./frontend/templates/
+ types: [ html ]
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
+ types: [ text ]
+ language: python
- id: end-of-file-fixer
- - id: debug-statements
- - id: name-tests-test
- - repo: https://github.com/asottile/setup-cfg-fmt
- rev: v2.5.0
- hooks:
- - id: setup-cfg-fmt
- - repo: https://github.com/asottile/pyupgrade
- rev: v3.15.2
- hooks:
- - id: pyupgrade
- args: [ --py39-plus ]
+ types: [ python ]
+ language: python
+ - id: detect-aws-credentials
+ - id: detect-private-key
+ exclude: "docs/getting-started/settings/AWS/static.md"
+ - id: check-added-large-files
+ - id: check-ast
+ types: [ python3 ]
+ language: python
+ files: ".*\\.py$" # may not be needed due to type of python3
+ - id: check-json
+ types: [ json ]
+ files: ".*\\.json$"
+ exclude: "backend/management/commands/contributors.json"
+ # - id: debug-statements # (unknown use)
+ # - id: name-tests-test # (blocking)
+ # - repo: https://github.com/asottile/setup-cfg-fmt
+ # rev: v2.5.0
+ # hooks:
+ # - id: setup-cfg-fmt
+ # - repo: https://github.com/asottile/pyupgrade
+ # rev: v3.15.2
+ # hooks:
+ # - id: pyupgrade # (blocking)
+ # args: [ --py39-plus ]
+ # - repo: https://github.com/pre-commit/mirrors-mypy
+ # rev: v1.7.0
+ # hooks:
+ # - id: mypy # (blocking)
+ # args:
+ # - --explicit-package-bases
+ # - --no-incremental
+ # additional_dependencies: ['mypy >=1.7.0, <1.8.0']
diff --git a/README.md b/README.md
index b37b331d..4631c97e 100644
--- a/README.md
+++ b/README.md
@@ -88,8 +88,8 @@ To contribute code:
3. Create a new branch for your changes.
4. Make your changes, following the coding style guidelines.
5. Test your changes thoroughly
- - `python manage.py test`
- - run the app (`python manage.py runserver`)
+ - `python3 manage.py test`
+ - run the app (`python3 manage.py runserver`)
- view any changed pages in browser (`http://127.0.0.1:8000`) and make sure the changes work as expected
6. Submit a pull request to the main repository's `main` branch.
@@ -112,6 +112,12 @@ pip install black
black ./
```
+For static type checking we are using [mypy](https://mypy-lang.org/). Code tests will be run before PRs can be merged, they will fail if types in you code will be incorrect. You can run check with this command:
+
+```
+mypy .
+```
+
### Version Control
We use Git. Make sure your commits are clear, concise, and well-documented. Follow conventional commit message style.
@@ -448,6 +454,30 @@ Thank you for your contributions!
๐
+
{{ notif_count | default:request.user.notification_count }}
diff --git a/frontend/templates/base/topbar/_notification_dropdown_items.html b/frontend/templates/base/topbar/_notification_dropdown_items.html index 3383d904..7d9e36d3 100644 --- a/frontend/templates/base/topbar/_notification_dropdown_items.html +++ b/frontend/templates/base/topbar/_notification_dropdown_items.html @@ -41,9 +41,21 @@ {% elif notification.action == "redirect" %}