From 6733f9016e36a43b50c0ed448258de300400e153 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Mon, 18 Jul 2022 15:55:30 -0400 Subject: [PATCH] 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 --- zproject/computed_settings.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py index 556f427eac3c66..53b8539cf1a508 100644 --- a/zproject/computed_settings.py +++ b/zproject/computed_settings.py @@ -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 @@ -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 = (