Skip to content

Commit

Permalink
settings: Add isinstance check before filtering.
Browse files Browse the repository at this point in the history
This is a follow-up to typeddjango/django-stubs#1038.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
  • Loading branch information
PIG208 committed Jul 22, 2022
1 parent a8217c5 commit 6733f90
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions zproject/computed_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import time
from copy import deepcopy
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union
from urllib.parse import urljoin

Expand Down Expand Up @@ -160,9 +161,16 @@


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()
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 = (
Expand Down

0 comments on commit 6733f90

Please sign in to comment.