Skip to content

Commit 7699fe8

Browse files
authored
Start using github actions matrix to run tests instead of tox and add running mypy (#30)
1 parent 7d58e87 commit 7699fe8

File tree

8 files changed

+32
-64
lines changed

8 files changed

+32
-64
lines changed

.github/workflows/run-tests.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"]
17-
django-version: ["django==4.2.*", "django==5.0.*", "django==5.1.*", "django==5.2.*"]
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17+
django-version: ["django==4.2.*", "django==5.0.*", "django==5.1.*"]
1818
exclude:
19-
- python-version: "3.12"
20-
django-version: "django<4.2.8"
21-
- python-version: "3.13.0-rc.1"
22-
django-version: "django<5.2"
19+
- python-version: "3.8"
20+
django-version: "django==5.0.*"
21+
- python-version: "3.8"
22+
django-version: "django==5.1.*"
23+
- python-version: "3.9"
24+
django-version: "django==5.0.*"
25+
- python-version: "3.9"
26+
django-version: "django==5.1.*"
27+
2328
steps:
2429
- uses: actions/checkout@v3
2530
- name: Set up Python ${{ matrix.python-version }}
@@ -29,10 +34,16 @@ jobs:
2934
- name: Install dependencies
3035
run: |
3136
python -m pip install --upgrade pip
32-
pip install -r requirements_test.txt
37+
pip install ${{ matrix.django-version }}
38+
echo ${{ matrix.django-version }} >> dj.txt
39+
pip install -c dj.txt -r requirements_test.txt
3340
- name: Lint with ruff
3441
run: |
3542
# stop the build if there are Python syntax errors or undefined names
3643
make ruff-check
37-
- name: Run Tox
38-
run: tox
44+
- name: MyPy
45+
run: mypy django_mail_viewer
46+
- name: Run Tests
47+
run: |
48+
coverage run --source django_mail_viewer runtests.py
49+
coverage report

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM python:3.8-bookworm AS dev
1+
ARG PYTHON_VERSION=3.8
2+
ARG DEBIAN_DISTRO=bookworm
3+
FROM python:${PYTHON_VERSION}-${DEBIAN_DISTRO} AS dev
24
# Dockerfile for running a test django installation
35
LABEL maintainer="Justin Michalicek <[email protected]>"
46
ENV PYTHONUNBUFFERED 1

django_mail_viewer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.2.0'
1+
__version__ = "2.2.0"

django_mail_viewer/backends/database/models.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import email.message
22
import email.utils
33
import json
4-
from typing import TYPE_CHECKING, Any, Dict, List, Union
4+
from typing import Any, Dict, List, Union
55

66
from django.db import models
77

@@ -12,7 +12,7 @@ class AbstractBaseEmailMessage(models.Model):
1212
storage for the Message FileField. Once Django 3.1+ only is supported then a callable may be used
1313
rendering this not really necessary.
1414
15-
To customize, subclass this and add a `FileField()` named `serialized_message_file` with the storage you would
15+
To customize, subclass this and add a `FileField()` named `file_attachment` with the storage you would
1616
like to use.
1717
"""
1818

@@ -30,17 +30,11 @@ class AbstractBaseEmailMessage(models.Model):
3030
created_at = models.DateTimeField(auto_now_add=True)
3131
updated_at = models.DateTimeField(auto_now=True)
3232

33+
file_attachment: models.FileField
34+
3335
class Meta:
3436
abstract = True
3537

36-
def __init__(self, *args, **kwargs):
37-
super().__init__(*args, **kwargs)
38-
39-
# methods here expect the concrete subclasses to implement the file_attachment field
40-
# should only be necessary until django 2.2 support is dropped... I hope
41-
if TYPE_CHECKING and not hasattr(self, "file_attachment"):
42-
self.file_attachment = models.FileField(blank=True, default="", upload_to="mailviewer_attachments")
43-
4438
# I really only need/use get_filename(), get_content_type(), get_payload(), walk()
4539
# returns Any due to failobj
4640
def get(self, attr: str, failobj: Any = None) -> Any:

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[tool.mypy]
22
plugins = ["mypy_django_plugin.main"]
3+
ignore_missing_imports = true
34
# for some reason this is not following the ignore of the settings file...
45
exclude = [
56
'migrations',
6-
'test_project\/test_project\/settings\.py'
7+
'test_project\/test_project\/settings\.py',
8+
'docs',
79
]
810

911
[tool.django-stubs]

requirements_test.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ flake8
44
pytest
55
tox
66
tox-gh-actions
7-
django-stubs
8-
mypy
7+
django-stubs[compatible-mypy]
98
typing-extensions
109
black
1110
ruff

test_project/__init__.py

Whitespace-only changes.

tox.ini

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)