From 61e149dbb57b6908641aa05e81764253e28fa687 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 13 Sep 2022 22:45:28 -0700 Subject: [PATCH] subdomain: Remove impossible None case from user_matches_subdomain. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only two callers pass get_subdomain(request) which can’t be None. Signed-off-by: Anders Kaseorg --- zerver/lib/subdomains.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zerver/lib/subdomains.py b/zerver/lib/subdomains.py index 325990c2f4..6cab4a5d0f 100644 --- a/zerver/lib/subdomains.py +++ b/zerver/lib/subdomains.py @@ -1,6 +1,5 @@ import re import urllib -from typing import Optional from django.conf import settings from django.http import HttpRequest @@ -46,9 +45,7 @@ def is_subdomain_root_or_alias(request: HttpRequest) -> bool: return get_subdomain(request) == Realm.SUBDOMAIN_FOR_ROOT_DOMAIN -def user_matches_subdomain(realm_subdomain: Optional[str], user_profile: UserProfile) -> bool: - if realm_subdomain is None: - return True # nocoverage # This state may no longer be possible. +def user_matches_subdomain(realm_subdomain: str, user_profile: UserProfile) -> bool: return user_profile.realm.subdomain == realm_subdomain