1+ from __future__ import annotations
2+
13import contextlib
24import logging
35import os
46import re
57from fnmatch import fnmatch
68from importlib import import_module
7- from typing import Set
9+ from typing import Any
810
911from django .template import engines
1012from django .utils .encoding import smart_str
@@ -68,9 +70,9 @@ def _get_loaders(self):
6870 loaders .append (loader )
6971 return loaders
7072
71- def _get_paths (self ) -> Set :
73+ def _get_paths (self ) -> set [ str ] :
7274 """Obtains a set of all template directories."""
73- paths = set ()
75+ paths : set [ str ] = set ()
7476 for loader in self ._get_loaders ():
7577 with contextlib .suppress (ImportError , AttributeError , TypeError ):
7678 module = import_module (loader .__module__ )
@@ -80,12 +82,12 @@ def _get_paths(self) -> Set:
8082 paths .update (smart_str (origin ) for origin in get_template_sources ("" ))
8183 return paths
8284
83- def _get_templates (self , paths : Set ) -> Set :
85+ def _get_templates (self , paths : set [ str ] ) -> set [ str ] :
8486 """Obtains a set of all HTML template paths."""
8587 extensions = [".html" ]
86- templates = set ()
88+ templates : set [ str ] = set ()
8789 for path in paths :
88- for root , dirs , files in os .walk (path , followlinks = False ):
90+ for root , _ , files in os .walk (path , followlinks = False ):
8991 templates .update (
9092 os .path .join (root , name )
9193 for name in files
@@ -95,9 +97,9 @@ def _get_templates(self, paths: Set) -> Set:
9597
9698 return templates
9799
98- def _get_components (self , templates : Set ) -> Set :
100+ def _get_components (self , templates : set [ str ] ) -> set [ str ] :
99101 """Obtains a set of all IDOM components by parsing HTML templates."""
100- components = set ()
102+ components : set [ str ] = set ()
101103 for template in templates :
102104 with contextlib .suppress (Exception ):
103105 with open (template , "r" , encoding = "utf-8" ) as template_file :
@@ -118,7 +120,7 @@ def _get_components(self, templates: Set) -> Set:
118120 )
119121 return components
120122
121- def _register_components (self , components : Set ) -> None :
123+ def _register_components (self , components : set [ str ] ) -> None :
122124 """Registers all IDOM components in an iterable."""
123125 for component in components :
124126 try :
0 commit comments