Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

decorator: Type zulip_login_required with overload.

PIG208f280ebe4b594
diff --git a/zerver/decorator.py b/zerver/decorator.py
index 6555478add2..8518225ffda 100644
--- a/zerver/decorator.py
+++ b/zerver/decorator.py
@@ -4,7 +4,7 @@ import logging
import urllib
from functools import wraps
from io import BytesIO
-from typing import Callable, Dict, Optional, Sequence, Tuple, TypeVar, Union, cast
+from typing import Callable, Dict, Optional, Sequence, Tuple, TypeVar, Union, cast, overload
import django_otp
from django.conf import settings
@@ -474,6 +474,24 @@ def human_users_only(view_func: ViewFuncT) -> ViewFuncT:
return cast(ViewFuncT, _wrapped_view_func) # https://github.com/python/mypy/issues/1927
+@overload
+def zulip_login_required(
+ function: ViewFuncT,
+ redirect_field_name: str = REDIRECT_FIELD_NAME,
+ login_url: str = settings.HOME_NOT_LOGGED_IN,
+) -> ViewFuncT:
+ ...
+
+
+@overload
+def zulip_login_required(
+ function: None,
+ redirect_field_name: str = REDIRECT_FIELD_NAME,
+ login_url: str = settings.HOME_NOT_LOGGED_IN,
+) -> Callable[[ViewFuncT], ViewFuncT]:
+ ...
+
+
# Based on Django 1.8's @login_required
def zulip_login_required(
function: Optional[ViewFuncT] = None,