From 9a1c60fd98dcf969df620e0ddac81bf48a69d979 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 13 Dec 2023 09:26:19 +0000 Subject: [PATCH 1/6] Make a note in toxfile --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index e086426..cee1679 100644 --- a/tox.ini +++ b/tox.ini @@ -47,6 +47,7 @@ deps = drf313: djangorestframework>=3.13,<3.14 drf314: djangorestframework>=3.14,<3.15 pytest: -rrequirements.txt + # Fix theses mypy: git+https://github.com/typeddjango/djangorestframework-stubs.git@946c7d60aaecdc9ef307f5e1f8eb55f7083ffb16#egg=djangorestframework-stubs mypy: djangorestframework-stubs commands= From 22b4214e9d51c6d8aa6547121b70738a57f37669 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 13 Dec 2023 09:36:43 +0000 Subject: [PATCH 2/6] Install latest version of djangorestframework-stubs, with correct version of mypy --- tox.ini | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index cee1679..4753448 100644 --- a/tox.ini +++ b/tox.ini @@ -47,9 +47,7 @@ deps = drf313: djangorestframework>=3.13,<3.14 drf314: djangorestframework>=3.14,<3.15 pytest: -rrequirements.txt - # Fix theses - mypy: git+https://github.com/typeddjango/djangorestframework-stubs.git@946c7d60aaecdc9ef307f5e1f8eb55f7083ffb16#egg=djangorestframework-stubs - mypy: djangorestframework-stubs + mypy: djangorestframework-stubs[compatible-mypy] commands= pytest: pytest --cov drf_writable_nested --cov-report=xml mypy: mypy example From a88cecf86353219bd30cfeab7fe1ef55d9c270b2 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 13 Dec 2023 09:37:22 +0000 Subject: [PATCH 3/6] Finish running the whole CI matrix before stopping --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cd33444..fbfac83 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,6 +8,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: include: - python-version: 3.7 From dcdd232424f28a61b16a30b7f0e732d1b4c3a9ec Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 13 Dec 2023 09:46:25 +0000 Subject: [PATCH 4/6] Ignore type error from mypy error: "type[UFMChild]" has no attribute "objects" [attr-defined] It's a Django model, this attribute exists... --- tests/serializers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/serializers.py b/tests/serializers.py index 811e035..3c5e46f 100644 --- a/tests/serializers.py +++ b/tests/serializers.py @@ -202,9 +202,10 @@ class Meta: class UFMChildSerializerForValidatorMessage(UniqueFieldsMixin, serializers.ModelSerializer): field = serializers.CharField(validators=[ - UniqueValidator(queryset=models.UFMChild.objects.all(), - message=UNIQUE_ERROR_MESSAGE - ) + UniqueValidator( + queryset=models.UFMChild.objects.all(), # type: ignore[attr-defined] + message=UNIQUE_ERROR_MESSAGE, + ) ]) class Meta: From 22770e6927d10ee1a523d2c7f145a9bbd5b3ab78 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 13 Dec 2023 09:58:23 +0000 Subject: [PATCH 5/6] Add --show-traceback to mypy runs --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 4753448..49f8c79 100644 --- a/tox.ini +++ b/tox.ini @@ -50,5 +50,5 @@ deps = mypy: djangorestframework-stubs[compatible-mypy] commands= pytest: pytest --cov drf_writable_nested --cov-report=xml - mypy: mypy example - mypy: mypy . + mypy: mypy --show-traceback example + mypy: mypy --show-traceback . From f99bddadb75360c4a0279c2cd2ce62996600bdaa Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 13 Dec 2023 10:13:17 +0000 Subject: [PATCH 6/6] Don't run mypy on older versions of Django --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 49f8c79..c542b12 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,10 @@ DJANGO_SETTINGS_MODULE = tests.settings [tox] envlist = - py{37,38}-dj{22}-drf{38,39,310,311}-{pytest,mypy} - py{37,38}-dj{30}-drf{310,311}-{pytest,mypy} - py{37,38,39,310,311}-dj{31,32}-drf{311,312,313,314}-{pytest,mypy} - py{38,39,310,311}-dj{40,41}-drf{313,314}-{pytest,mypy} + py{37,38}-dj{22}-drf{38,39,310,311}-pytest + py{37,38}-dj{30}-drf{310,311}-pytest + py{37,38,39,310,311}-dj{31,32}-drf{311,312,313,314}-pytest + py{38,39,310,311}-dj{40,41}-drf{313,314}-pytest py{38,39,310,311}-dj{42}-drf{314}-{pytest,mypy} skip_missing_interpreters = true