mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 16:14:02 +00:00
mypy: Enable strict-optional for auth.py.
This commit is contained in:
committed by
Tim Abbott
parent
f3ef2a186c
commit
3d43682f1b
2
mypy.ini
2
mypy.ini
@@ -90,8 +90,6 @@ strict_optional = True
|
||||
[mypy-zerver.webhooks.gitlab.view]
|
||||
strict_optional = False
|
||||
|
||||
[mypy-zerver.views.auth] # Other issues in this file too
|
||||
strict_optional = False
|
||||
[mypy-zerver.views.realm] # Other issues in this file too
|
||||
strict_optional = False
|
||||
[mypy-zerver.views.messages] # Other issues in this file too
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict
|
||||
from django.http import HttpRequest
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
@@ -35,7 +35,7 @@ def common_context(user: UserProfile) -> Dict[str, Any]:
|
||||
'user_name': user.full_name,
|
||||
}
|
||||
|
||||
def get_realm_from_request(request: HttpRequest) -> Optional[Realm]:
|
||||
def get_realm_from_request(request: HttpRequest) -> Realm:
|
||||
if hasattr(request, "user") and hasattr(request.user, "realm"):
|
||||
return request.user.realm
|
||||
if not hasattr(request, "realm"):
|
||||
|
@@ -148,7 +148,7 @@ def redirect_to_subdomain_login_url() -> HttpResponseRedirect:
|
||||
def redirect_to_config_error(error_type: str) -> HttpResponseRedirect:
|
||||
return HttpResponseRedirect("/config-error/%s" % (error_type,))
|
||||
|
||||
def login_or_register_remote_user(request: HttpRequest, remote_username: Optional[str],
|
||||
def login_or_register_remote_user(request: HttpRequest, remote_username: str,
|
||||
user_profile: Optional[UserProfile], full_name: str='',
|
||||
invalid_subdomain: bool=False, mobile_flow_otp: Optional[str]=None,
|
||||
is_signup: bool=False, redirect_to: str='',
|
||||
@@ -307,7 +307,7 @@ def google_oauth2_csrf(request: HttpRequest, value: str) -> str:
|
||||
token = _unsalt_cipher_token(get_token(request))
|
||||
return hmac.new(token.encode('utf-8'), value.encode("utf-8"), hashlib.sha256).hexdigest()
|
||||
|
||||
def reverse_on_root(viewname: str, args: List[str]=None, kwargs: Dict[str, str]=None) -> str:
|
||||
def reverse_on_root(viewname: str, *args: str, **kwargs: str) -> str:
|
||||
return settings.ROOT_DOMAIN_URI + reverse(viewname, args=args, kwargs=kwargs)
|
||||
|
||||
def oauth_redirect_to_root(request: HttpRequest, url: str,
|
||||
|
Reference in New Issue
Block a user