settings: Add isinstance check before filtering.

This is a follow-up to https://github.com/typeddjango/django-stubs/pull/1038.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-18 15:55:30 -04:00 committed by Tim Abbott
parent 35778fa100
commit 036a90f375
1 changed files with 10 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import os
import sys import sys
import time import time
from copy import deepcopy from copy import deepcopy
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union from typing import Any, Dict, List, Tuple, Union
from urllib.parse import urljoin from urllib.parse import urljoin
@ -159,9 +160,16 @@ ALLOWED_HOSTS += REALM_HOSTS.values()
class TwoFactorLoader(app_directories.Loader): class TwoFactorLoader(app_directories.Loader):
def get_dirs(self) -> List[Union[bytes, str]]: def get_dirs(self) -> List[Union[str, Path]]:
dirs = super().get_dirs() dirs = super().get_dirs()
return [d for d in dirs if d.match("two_factor/*")] # app_directories.Loader returns only a list of
# Path objects by calling get_app_template_dirs
two_factor_dirs: List[Union[str, Path]] = []
for d in dirs:
assert isinstance(d, Path)
if d.match("two_factor/*"):
two_factor_dirs.append(d)
return two_factor_dirs
MIDDLEWARE = ( MIDDLEWARE = (