Skip to content

Commit 7bf13d6

Browse files
authored
Merge branch 'master' into ValidationError-params
2 parents 9069938 + 92c8c45 commit 7bf13d6

File tree

20 files changed

+115
-108
lines changed

20 files changed

+115
-108
lines changed

.github/workflows/pre-commit-autoupdate.yml

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

.github/workflows/test.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
mypy-self-check:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
pip install -U pip setuptools wheel
25+
pip install -r ./requirements.txt
26+
- name: Run mypy on plugin code
27+
run: mypy --strict mypy_drf_plugin
28+
- name: Run mypy on scripts and utils
29+
run: mypy --strict scripts
30+
- name: Run mypy on stubs
31+
run: mypy --cache-dir=/dev/null --no-incremental rest_framework-stubs
32+
1133
lint:
1234
runs-on: ubuntu-latest
1335
strategy:
@@ -31,7 +53,7 @@ jobs:
3153
runs-on: ubuntu-latest
3254
strategy:
3355
matrix:
34-
python-version: ['3.7', '3.8', '3.9', '3.10']
56+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
3557
steps:
3658
- uses: actions/checkout@v3
3759
- name: Setup system dependencies
@@ -54,7 +76,7 @@ jobs:
5476
runs-on: ubuntu-latest
5577
strategy:
5678
matrix:
57-
python-version: ['3.7', '3.8', '3.9', '3.10']
79+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
5880
steps:
5981
- uses: actions/checkout@v3
6082
- name: Setup system dependencies

.pre-commit-config.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ repos:
1515
hooks:
1616
- id: pyupgrade
1717
args: ["--py36-plus"]
18-
- repo: https://github.com/pre-commit/mirrors-isort
19-
rev: v5.10.1
18+
- repo: https://github.com/pycqa/isort
19+
rev: 5.12.0
2020
hooks:
2121
- id: isort
22+
name: isort (python)
23+
- id: isort
24+
name: isort (pyi)
25+
types: [pyi]
2226
- repo: https://github.com/psf/black
2327
rev: 23.1.0
2428
hooks:
@@ -31,12 +35,10 @@ repos:
3135
- flake8-pyi==22.11.0
3236
types: []
3337
files: ^.*.pyi?$
34-
- repo: local
35-
hooks:
36-
- id: mypy
37-
name: mypy
38-
entry: mypy
39-
language: system
40-
types: [ python ]
41-
exclude: "scripts/*"
42-
args: [ "--cache-dir=/dev/null", "--no-incremental" ]
38+
39+
ci:
40+
autofix_commit_msg: '[pre-commit.ci] auto fixes from pre-commit.com hooks'
41+
autofix_prs: true
42+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
43+
autoupdate_schedule: weekly
44+
submodules: false

mypy_drf_plugin/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable, Dict, Optional
1+
from typing import Callable, Dict, Optional, Type
22

33
from mypy.nodes import TypeInfo
44
from mypy.options import Options
@@ -28,9 +28,10 @@ def __init__(self, options: Options) -> None:
2828
def _get_currently_defined_serializers(self) -> Dict[str, int]:
2929
base_serializer_sym = self.lookup_fully_qualified(fullnames.BASE_SERIALIZER_FULLNAME)
3030
if base_serializer_sym is not None and isinstance(base_serializer_sym.node, TypeInfo):
31-
return base_serializer_sym.node.metadata.setdefault("drf", {}).setdefault(
31+
serializer_bases: Dict[str, int] = base_serializer_sym.node.metadata.setdefault("drf", {}).setdefault(
3232
"serializer_bases", {fullnames.BASE_SERIALIZER_FULLNAME: 1}
3333
)
34+
return serializer_bases
3435
else:
3536
return {}
3637

@@ -40,5 +41,5 @@ def get_base_class_hook(self, fullname: str) -> Optional[Callable[[ClassDefConte
4041
return None
4142

4243

43-
def plugin(version):
44+
def plugin(version: str) -> Type[NewSemanalDRFPlugin]:
4445
return NewSemanalDRFPlugin

requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
wheel
2-
gitpython==3.1.30
2+
gitpython==3.1.31
33
pre-commit==2.21.0
44
pytest==7.2.1
55
pytest-mypy-plugins==1.10.1
66
djangorestframework==3.14.0
7-
types-pytz==2022.7.1.0
8-
types-requests==2.28.11.8
9-
types-urllib3==1.26.25.4
10-
django-stubs==1.13.0
7+
types-pytz==2022.7.1.2
8+
types-requests==2.28.11.14
9+
types-urllib3==1.26.25.7
10+
django-stubs==1.15.0
1111
django-stubs-ext==0.7.0
1212
-e .[compatible-mypy,coreapi,markdown]

rest_framework-stubs/generics.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from typing import Any, Protocol, TypeVar
33

44
from django.db.models import Manager, Model
55
from django.db.models.query import QuerySet
6-
76
from rest_framework import mixins, views
87
from rest_framework.filters import BaseFilterBackend
98
from rest_framework.pagination import BasePagination

rest_framework-stubs/mixins.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Any, TypeVar
22

33
from django.db.models import Model
4-
54
from rest_framework.generics import UsesQuerySet
65
from rest_framework.request import Request
76
from rest_framework.response import Response

rest_framework-stubs/permissions.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from collections.abc import Sequence
22
from typing import Any, Protocol, Union # noqa: Y037 # https://github.com/python/mypy/issues/12392
3-
from typing_extensions import TypeAlias
43

54
from django.db.models import Model, QuerySet
65
from rest_framework.request import Request
76
from rest_framework.views import APIView
7+
from typing_extensions import TypeAlias
88

99
SAFE_METHODS: Sequence[str]
1010

rest_framework-stubs/relations.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from collections import OrderedDict
22
from collections.abc import Callable, Iterable, Mapping, Sequence
33
from typing import Any, Generic, TypeVar
4-
from _typeshed import Self
54

5+
from _typeshed import Self
66
from django.db.models import Manager, Model, QuerySet
77
from rest_framework.fields import Field, Option
88
from rest_framework.request import Request

rest_framework-stubs/renderers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from json import JSONEncoder
21
from collections.abc import Iterable, Mapping, Sequence
2+
from json import JSONEncoder
33
from typing import Any
44

55
from django import forms

0 commit comments

Comments
 (0)