Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -48,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Setup system dependencies
Expand Down
4 changes: 2 additions & 2 deletions mypy_drf_plugin/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Optional
from collections.abc import Callable

from mypy.nodes import TypeInfo
from mypy.plugin import ClassDefContext, Plugin
Expand Down Expand Up @@ -26,7 +26,7 @@ def _get_currently_defined_serializers(self) -> dict[str, int]:
else:
return {}

def get_base_class_hook(self, fullname: str) -> Optional[Callable[[ClassDefContext], None]]:
def get_base_class_hook(self, fullname: str) -> Callable[[ClassDefContext], None] | None:
if fullname in self._get_currently_defined_serializers():
return transform_serializer_class
return None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.ruff]
line-length = 120
target-version = "py39"
target-version = "py310"
# See Rules in Ruff documentation: https://docs.astral.sh/ruff/rules/
[tool.ruff.lint]
select = [
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ types-pytz==2025.2.0.20250326
types-requests==2.32.0.20250328
types-urllib3==1.26.25.14
types-Pygments==2.19.0.20250305
types-pyyaml==6.0.12.20250402
django-stubs[compatible-mypy] @ git+https://github.com/typeddjango/django-stubs
django-stubs-ext @ git+https://github.com/typeddjango/django-stubs#subdirectory=ext
-e .[compatible-mypy,coreapi,markdown]
3 changes: 1 addition & 2 deletions rest_framework-stubs/compat.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any
from typing import Any, TypeAlias

from django.db.models import QuerySet
from typing_extensions import TypeAlias

try:
from django.contrib.postgres import fields as postgres_fields
Expand Down
4 changes: 2 additions & 2 deletions rest_framework-stubs/decorators.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from collections.abc import Callable, Mapping, Sequence
from typing import Any, Literal, Protocol, TypeVar
from typing import Any, Concatenate, Literal, Protocol, TypeAlias, TypeVar

from django.http import HttpRequest
from django.http.response import HttpResponseBase
Expand All @@ -12,7 +12,7 @@ from rest_framework.request import Request
from rest_framework.schemas.inspectors import ViewInspector
from rest_framework.throttling import BaseThrottle
from rest_framework.views import APIView, AsView # noqa: F401
from typing_extensions import Concatenate, ParamSpec, TypeAlias
from typing_extensions import ParamSpec

_View = TypeVar("_View", bound=Callable[..., HttpResponseBase])
_P = ParamSpec("_P")
Expand Down
4 changes: 2 additions & 2 deletions rest_framework-stubs/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from collections.abc import Mapping, Sequence
from typing import Any
from typing import Any, TypeAlias

from django.http import HttpRequest, JsonResponse
from django_stubs_ext import StrOrPromise
from rest_framework.renderers import BaseRenderer
from rest_framework.request import Request
from typing_extensions import Self, TypeAlias, TypedDict
from typing_extensions import Self, TypedDict

class ErrorDetail(str):
code: str | None
Expand Down
4 changes: 2 additions & 2 deletions rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ from decimal import Decimal
from enum import Enum
from json import JSONDecoder, JSONEncoder
from re import Pattern
from typing import Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar
from typing import Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeAlias, TypeVar

from django.core.files.base import File
from django.db import models
from django.forms import ImageField as DjangoImageField # noqa: F401
from django_stubs_ext import StrOrPromise
from rest_framework.serializers import BaseSerializer
from rest_framework.validators import Validator
from typing_extensions import Self, TypeAlias
from typing_extensions import Self

class _Empty(Enum):
sentinel = 0
Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/permissions.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from typing import Any, Protocol
from typing import Any, Protocol, TypeAlias

from django.db.models import Model, QuerySet
from rest_framework.request import Request
from rest_framework.views import APIView
from typing_extensions import TypeAlias

SAFE_METHODS: Sequence[str]

Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/schemas/generators.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Sequence
from types import ModuleType
from typing import Any
from typing import Any, TypeAlias

from django.db.models.base import Model
from rest_framework.compat import coreapi
from rest_framework.request import Request
from rest_framework.urlpatterns import _AnyURL
from rest_framework.views import APIView
from typing_extensions import TypeAlias

def common_path(paths: Iterable[str]) -> str: ...
def get_pk_name(model: type[Model]) -> str: ...
Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/test.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping
from typing import Any
from typing import Any, TypeAlias

import coreapi # type: ignore[import-untyped]
import requests
Expand All @@ -15,7 +15,6 @@ from django.test.client import RequestFactory as DjangoRequestFactory
from rest_framework.authtoken.models import Token
from rest_framework.request import Request
from rest_framework.response import _MonkeyPatchedResponse
from typing_extensions import TypeAlias

_GetDataType: TypeAlias = (
Mapping[str, str | bytes | float | Iterable[str | bytes | float]]
Expand Down
2 changes: 1 addition & 1 deletion rest_framework-stubs/urlpatterns.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Iterable, Sequence
from typing import TypeAlias

from django.urls.resolvers import URLPattern, URLResolver
from typing_extensions import TypeAlias

_AnyURL: TypeAlias = URLPattern | URLResolver

Expand Down
3 changes: 2 additions & 1 deletion rest_framework-stubs/utils/json.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable
from json import JSONDecoder, JSONEncoder
from typing import IO, Any, Callable, NoReturn
from typing import IO, Any, NoReturn

def strict_constant(o: Any) -> NoReturn: ...
def dump(
Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/validators.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from collections.abc import Callable, Container, Iterable, MutableMapping
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeAlias, TypeVar

from django.db.models import Model, QuerySet
from django_stubs_ext import StrOrPromise
from rest_framework.fields import Field
from rest_framework.serializers import BaseSerializer
from typing_extensions import TypeAlias

_T = TypeVar("_T", bound=Model)
_V = TypeVar("_V", contravariant=True)
Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/viewsets.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable
from typing import Any
from typing import Any, TypeAlias

from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
Expand All @@ -8,7 +8,6 @@ from rest_framework.decorators import ViewSetAction
from rest_framework.generics import _MT_co
from rest_framework.request import Request
from rest_framework.views import AsView, GenericView
from typing_extensions import TypeAlias

def _is_extra_action(attr: Any) -> bool: ...

Expand Down
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def find_stub_files(name: str) -> list[str]:
readme = f.read()

dependencies = [
"django-stubs>=5.1.3",
"typing-extensions>=3.10.0",
"requests>=2.0.0",
"types-requests>=0.1.12",
"types-PyYAML>=5.4.3",
"django-stubs>=5.1.3", # TODO: 5.2
"typing-extensions>=4.0",
"requests>=2.0",
"types-requests",
"types-PyYAML",
]

# Keep compatible-mypy major.minor version pinned to what latest django-stubs release uses.
Expand All @@ -49,11 +49,10 @@ def find_stub_files(name: str) -> list[str]:
extras_require=extras_require,
packages=["rest_framework-stubs", *find_packages(exclude=["scripts"])],
package_data={"rest_framework-stubs": find_stub_files("rest_framework-stubs")},
python_requires=">=3.9",
python_requires=">=3.10",
classifiers=[
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down