Skip to content

Commit a97bb5d

Browse files
committed
Update linting packages and fix new issues
1 parent 964018d commit a97bb5d

File tree

13 files changed

+39
-33
lines changed

13 files changed

+39
-33
lines changed

drf_spectacular/plumbing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ class Choices: # type: ignore
100100
else:
101101
CACHED_PROPERTY_FUNCS = (cached_property,)
102102

103-
T = TypeVar('T')
104-
105103

106104
class _Sentinel:
107105
pass
@@ -301,7 +299,7 @@ def build_basic_type(obj: Union[_KnownPythonTypes, OpenApiTypes]) -> Optional[_S
301299
elif obj in openapi_type_mapping:
302300
return dict(openapi_type_mapping[obj])
303301
elif obj in PYTHON_TYPE_MAPPING:
304-
return dict(openapi_type_mapping[PYTHON_TYPE_MAPPING[obj]])
302+
return dict(openapi_type_mapping[PYTHON_TYPE_MAPPING[obj]]) # type: ignore[index]
305303
else:
306304
warn(f'could not resolve type for "{obj}". defaulting to "string"')
307305
return dict(openapi_type_mapping[OpenApiTypes.STR])
@@ -818,6 +816,9 @@ def build(self, extra_components) -> _SchemaType:
818816
}
819817

820818

819+
T = TypeVar('T', bound="OpenApiGeneratorExtension")
820+
821+
821822
class OpenApiGeneratorExtension(Generic[T], metaclass=ABCMeta):
822823
_registry: List[Type[T]] = []
823824
target_class: Union[None, str, Type[object]] = None
@@ -870,7 +871,7 @@ def _matches(cls, target: Any) -> bool:
870871
return get_class(target) == cls.target_class
871872

872873
@classmethod
873-
def get_match(cls, target) -> Optional[T]:
874+
def get_match(cls, target: Any) -> Optional[T]:
874875
for extension in sorted(cls._registry, key=lambda e: e.priority, reverse=True):
875876
if extension._matches(target):
876877
return extension(target)

requirements/linting-base.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Django==4.2.25
2-
djangorestframework==3.14.0
1+
Django==5.2.7
2+
djangorestframework==3.16.1

requirements/linting.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pytest # required for mypy to succeed
22
flake8
3-
isort==5.12.0 # 5.13 somehow breaks django-stubs plugin
4-
mypy==1.7.1
5-
django-stubs==4.2.3
6-
djangorestframework-stubs==3.14.2
3+
isort==7.0.0
4+
mypy==1.18.2
5+
django-stubs[compatible-mypy]==5.2.7
6+
djangorestframework-stubs[compatible-mypy]==3.16.5

tests/contrib/test_drf_spectacular_sidecar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_sidecar_shortcut_urls_are_resolved(no_warnings):
3434
def test_sidecar_package_urls_matching(no_warnings):
3535
# poor man's test to make sure the sidecar package contents match with what
3636
# collectstatic is going to compile. cannot be tested directly.
37-
import drf_spectacular_sidecar # type: ignore[import-not-found]
37+
import drf_spectacular_sidecar
3838
module_root = os.path.dirname(inspect.getfile(drf_spectacular_sidecar))
3939
bundle_path = os.path.join(module_root, BUNDLE_URL)
4040
assert os.path.isfile(bundle_path)

tests/contrib/test_pydantic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
class BaseModel: # type: ignore
1616
pass
1717

18-
def dataclass(f):
18+
def dataclass(f): # type: ignore[no-redef]
1919
return f
2020

21-
def computed_field(f):
21+
def computed_field(f): # type: ignore[no-redef]
2222
return f
2323

2424

@@ -37,7 +37,7 @@ class A(BaseModel):
3737
b: B
3838
d: Decimal
3939

40-
@computed_field # type: ignore[misc]
40+
@computed_field # type: ignore[prop-decorator]
4141
@property
4242
def x(self) -> int:
4343
return 42
@@ -57,13 +57,13 @@ def post(self, request):
5757

5858
@pytest.mark.contrib('pydantic')
5959
@pytest.mark.skipif(sys.version_info < (3, 9), reason='python 3.9+ is required by package')
60-
def test_pydantic_as_query_parameters(no_warnings):
60+
def test_pydantic_as_query_parameters(no_warnings) -> None:
6161
class QueryParams(BaseModel):
6262
foo: int
6363
bar: str
6464

6565
class XAPIView(APIView):
66-
@extend_schema(responses=str, parameters=[QueryParams])
66+
@extend_schema(responses=str, parameters=[QueryParams]) # type: ignore[list-item]
6767
def get(self, request):
6868
pass # pragma: no cover
6969

tests/contrib/test_rest_framework_dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.mark.contrib('rest_framework_dataclasses')
1313
@pytest.mark.skipif(sys.version_info < (3, 7), reason='dataclass required by package')
14-
def test_rest_framework_dataclasses(no_warnings):
14+
def test_rest_framework_dataclasses(no_warnings) -> None:
1515
from dataclasses import dataclass
1616

1717
from rest_framework_dataclasses.serializers import DataclassSerializer
@@ -94,7 +94,7 @@ def custom_name_via_serializer_decoration(request):
9494

9595
@pytest.mark.contrib('rest_framework_dataclasses')
9696
@pytest.mark.skipif(sys.version_info < (3, 7), reason='dataclass required by package')
97-
def test_rest_framework_dataclasses_class_reuse(no_warnings):
97+
def test_rest_framework_dataclasses_class_reuse(no_warnings) -> None:
9898
from dataclasses import dataclass
9999

100100
from rest_framework_dataclasses.serializers import DataclassSerializer

tests/contrib/test_rest_framework_gis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55
from django.db import models
6-
from rest_framework import __version__ as DRF_VERSION # type: ignore[attr-defined]
6+
from rest_framework import __version__ as DRF_VERSION
77
from rest_framework import mixins, routers, serializers, viewsets
88

99
from drf_spectacular.utils import extend_schema_serializer

tests/contrib/test_simplejwt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
TokenObtainPairView, TokenObtainSlidingView, TokenRefreshView, TokenVerifyView,
1515
)
1616
except ImportError:
17-
JWTAuthentication = None
18-
JWTTokenUserAuthentication = None
17+
JWTAuthentication = None # type: ignore[misc,assignment]
18+
JWTTokenUserAuthentication = None # type: ignore[misc,assignment]
1919

2020

2121
class XSerializer(serializers.Serializer):

tests/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from rest_framework import __version__ as DRF_VERSION # type: ignore[attr-defined]
2+
from rest_framework import __version__ as DRF_VERSION
33
from rest_framework import generics, pagination, serializers, status, viewsets
44
from rest_framework.decorators import action
55
from rest_framework.response import Response

tests/test_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class AllFields(models.Model):
116116
field_json = models.JSONField()
117117
else:
118118
@property
119-
def field_json(self):
119+
def field_json(self): # type: ignore[misc]
120120
return {'A': 1, 'B': 2}
121121

122122
@property

0 commit comments

Comments
 (0)