Skip to content

Commit

Permalink
quickfix for PoC
Browse files Browse the repository at this point in the history
  • Loading branch information
c4ffein committed Aug 20, 2024
1 parent 9b385d9 commit 69146f6
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions ninja/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
from ninja.types import DictStrAny
from ninja.utils import check_csrf, is_async_callable

try:
from asgiref.sync import sync_to_async
except ModuleNotFoundError:
sync_to_async = None

if TYPE_CHECKING:
from ninja import NinjaAPI, Router # pragma: no cover

Expand Down Expand Up @@ -462,12 +457,9 @@ def get_view(self) -> Callable:
is_async = self.is_async
operations = self.operations
allowed_methods = {method for op in operations for method in op.methods}
response_not_allowed = (
HttpResponseNotAllowed(allowed_methods, content=b"Method not allowed"),
)

if is_async:
assert sync_to_async # Ensure we fail here and not in view
from asgiref.sync import sync_to_async

def sync_view(request: HttpRequest, *a: Any, **kw: Any) -> HttpResponseBase:
operation = next(
Expand Down

0 comments on commit 69146f6

Please sign in to comment.