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 @@ -14,9 +14,9 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'
python-version: '3.12'
- name: Install Flit
run: pip install flit
run: pip install flit "django>=5.2"
- name: Install Dependencies
run: make install
- name: Test
Expand Down
27 changes: 24 additions & 3 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,38 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
django-version: [ '<3.2', '<3.3', '<4.2', '<4.3', '<5.1' ]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
django-version: ['<3.2', '<3.3', '<4.2', '<4.3', '<5.1', '<5.2', '<5.3', '<6.1']
exclude:
- python-version: '3.8'
django-version: '<5.1'

- python-version: '3.9'
django-version: '<5.1'

- python-version: '3.12'
django-version: '<3.2'
- python-version: '3.12'
django-version: '<3.3'

- python-version: '3.13'
django-version: '<3.2'
- python-version: '3.13'
django-version: '<3.3'

# as of oct 2025 looks like django < 5.2 does not support python 3.14
- python-version: '3.14'
django-version: '<3.2'
- python-version: '3.14'
django-version: '<3.3'
- python-version: '3.14'
django-version: '<4.2'
- python-version: '3.14'
django-version: '<4.3'
- python-version: '3.14'
django-version: '<5.1'
- python-version: '3.14'
django-version: '<5.2'
steps:
- uses: actions/checkout@v6
- name: Set up Python
Expand All @@ -42,7 +63,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'
python-version: '3.12'
- name: Install Flit
run: pip install flit
- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion ninja_extra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Django Ninja Extra - Class Based Utility and more for Django Ninja(Fast Django REST framework)"""

__version__ = "0.30.6"
__version__ = "0.30.8"

import django

Expand Down
38 changes: 0 additions & 38 deletions ninja_extra/controllers/route/route_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import inspect
import warnings
from contextlib import contextmanager
from functools import wraps
from typing import TYPE_CHECKING, Any, Callable, Iterator, Optional, Tuple, cast
Expand Down Expand Up @@ -114,23 +113,6 @@ def as_view(
as_view.get_route_function = lambda: self # type:ignore
return as_view

def _process_view_function_result(self, result: Any) -> Any:
"""
This process any a returned value from view_func
and creates an api response if a result is ControllerResponseSchema

deprecated:: 0.21.5
This method is deprecated and will be removed in a future version.
The result processing should be handled by the response handlers.
"""
warnings.warn(
"_process_view_function_result() is deprecated and will be removed in a future version. "
"The result processing should be handled by the response handlers.",
DeprecationWarning,
stacklevel=2,
)
return result

def _get_controller_instance(self) -> "ControllerBase":
from ninja_extra.controllers.base import ModelControllerBase

Expand All @@ -155,26 +137,6 @@ def _get_controller_instance(self) -> "ControllerBase":

return controller_instance

def get_route_execution_context(
self, request: HttpRequest, *args: Any, **kwargs: Any
) -> RouteContext:
warnings.warn(
"get_route_execution_context() is deprecated in favor of "
"ninja_extra.controllers.route.context.get_route_execution_context()",
DeprecationWarning,
stacklevel=2,
)

init_kwargs = {
"permission_classes": self.route.permissions
or self.api_controller.permission_classes,
"request": request,
"kwargs": kwargs,
"args": args,
}
context = RouteContext(**init_kwargs) # type:ignore[arg-type]
return context

@contextmanager
def _prep_controller_route_execution(
self, route_context: RouteContext, **kwargs: Any
Expand Down
4 changes: 3 additions & 1 deletion ninja_extra/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def __new__(

def __eq__(self, other: object) -> bool:
r = super().__eq__(other)
if r is NotImplemented:
return NotImplemented # pragma: no cover
try:
return r and self.code == other.code # type: ignore
except AttributeError:
except AttributeError: # pragma: no cover
return r

def __ne__(self, other: object) -> bool:
Expand Down
31 changes: 0 additions & 31 deletions tests/test_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from ninja_extra import api_controller, permissions, route
from ninja_extra.constants import ROUTE_OBJECT
from ninja_extra.context import (
RouteContext,
get_route_execution_context,
)
from ninja_extra.controllers import (
Expand All @@ -20,7 +19,6 @@
from ninja_extra.controllers.base import get_route_functions
from ninja_extra.controllers.utils import get_api_controller
from ninja_extra.exceptions import PermissionDenied
from ninja_extra.permissions import AllowAny
from ninja_extra.reflect import reflect

from .schemas import UserSchema
Expand Down Expand Up @@ -320,22 +318,6 @@ def test_get_required_api_func_signature_return_filtered_signature(self):
assert len(sig_parameter) == 1
assert str(sig_parameter[0]).replace(" ", "") == "example_id:str"

def test_get_route_execution_context(self):
route.get("")(self.api_func)
route_object = reflect.get_metadata_or_raise_exception(
ROUTE_OBJECT, self.api_func
)
route_function = RouteFunction(route_object, Mock())
route_function.api_controller.permission_classes = [AllowAny]

route_context = route_function.get_route_execution_context(
anonymous_request, "arg1", "arg2", extra="extra"
)
assert isinstance(route_context, RouteContext)
expected_keywords = ("permission_classes", "request", "args", "kwargs")
for key in expected_keywords:
assert getattr(route_context, key)

def test_get_controller_instance_return_controller_instance(
self, get_route_function
):
Expand All @@ -348,19 +330,6 @@ def test_get_controller_instance_return_controller_instance(
assert isinstance(controller_instance, SomeTestController)
assert controller_instance.context is None

def test_process_view_function_result_return_tuple_or_input(
self, get_route_function
):
route_function: RouteFunction = get_route_function(SomeTestController().example)
mock_result = {"detail": "Some Message", "status_code": 302}
response = route_function._process_view_function_result(mock_result)
assert response == mock_result

mock_result = {"status": 302, "message": "Some Message"}
response = route_function._process_view_function_result(mock_result)
assert not isinstance(response, tuple)
assert response == mock_result


@pytest.mark.django_db
class TestAPIControllerRoutePermission:
Expand Down