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
89
910from django .template import engines
1011from django .utils .encoding import smart_str
@@ -68,9 +69,9 @@ def _get_loaders(self):
6869 loaders .append (loader )
6970 return loaders
7071
71- def _get_paths (self ) -> Set :
72+ def _get_paths (self ) -> set [ str ] :
7273 """Obtains a set of all template directories."""
73- paths = set ()
74+ paths : set [ str ] = set ()
7475 for loader in self ._get_loaders ():
7576 with contextlib .suppress (ImportError , AttributeError , TypeError ):
7677 module = import_module (loader .__module__ )
@@ -80,12 +81,12 @@ def _get_paths(self) -> Set:
8081 paths .update (smart_str (origin ) for origin in get_template_sources ("" ))
8182 return paths
8283
83- def _get_templates (self , paths : Set ) -> Set :
84+ def _get_templates (self , paths : set [ str ] ) -> set [ str ] :
8485 """Obtains a set of all HTML template paths."""
8586 extensions = [".html" ]
86- templates = set ()
87+ templates : set [ str ] = set ()
8788 for path in paths :
88- for root , dirs , files in os .walk (path , followlinks = False ):
89+ for root , _ , files in os .walk (path , followlinks = False ):
8990 templates .update (
9091 os .path .join (root , name )
9192 for name in files
@@ -95,9 +96,9 @@ def _get_templates(self, paths: Set) -> Set:
9596
9697 return templates
9798
98- def _get_components (self , templates : Set ) -> Set :
99+ def _get_components (self , templates : set [ str ] ) -> set [ str ] :
99100 """Obtains a set of all IDOM components by parsing HTML templates."""
100- components = set ()
101+ components : set [ str ] = set ()
101102 for template in templates :
102103 with contextlib .suppress (Exception ):
103104 with open (template , "r" , encoding = "utf-8" ) as template_file :
@@ -118,7 +119,7 @@ def _get_components(self, templates: Set) -> Set:
118119 )
119120 return components
120121
121- def _register_components (self , components : Set ) -> None :
122+ def _register_components (self , components : set [ str ] ) -> None :
122123 """Registers all IDOM components in an iterable."""
123124 for component in components :
124125 try :
0 commit comments