Skip to content

Commit

Permalink
fix requires_gis decorator
Browse files Browse the repository at this point in the history
would crash with argument mismatch.
  • Loading branch information
srepmub committed Dec 4, 2023
1 parent 83c2001 commit 6e22c19
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions odata_query/django/django_q.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import operator
from contextlib import contextmanager
from functools import wraps
from typing import Any, Callable, Dict, List, Optional, Type, Union
from uuid import UUID

Expand Down Expand Up @@ -52,13 +53,15 @@
}


@contextmanager
def requires_gis(*args, **kwargs):
if not gis_functions:
raise ImportError(
"Cannot use geography functions because GeoDjango failed to load."
) from _gis_error
yield
def requires_gis(func):
@wraps(func)
def wrapper(*args, **kwargs):
if not gis_functions:
raise ImportError(
"Cannot use geography functions because GeoDjango failed to load."
) from _gis_error
return func(*args, **kwargs)
return wrapper


class AstToDjangoQVisitor(visitor.NodeVisitor):
Expand Down

0 comments on commit 6e22c19

Please sign in to comment.