@@ -69,10 +69,11 @@ class ImpAllTest(impall.ImpAllTest):
6969import os
7070import sys
7171import traceback
72- import typing as t
7372import unittest
7473import warnings
74+ from collections .abc import Callable , Iterator , Sequence
7575from types import ModuleType
76+ from typing import Any
7677
7778__author__ = 'Tom Ritchford <tom@swirly.com>'
7879__all__ = 'ImpAllTest' , 'path_to_import'
@@ -134,11 +135,11 @@ class ImpAllTest(unittest.TestCase):
134135 VERBOSE = False
135136
136137 @functools .cached_property
137- def _exc (self ) -> t . Callable [[t . Any ], bool ]:
138+ def _exc (self ) -> Callable [[Any ], bool ]:
138139 return _split_pattern (self .EXCLUDE , self .paths )
139140
140141 @functools .cached_property
141- def _inc (self ) -> t . Callable [[t . Any ], bool ]:
142+ def _inc (self ) -> Callable [[Any ], bool ]:
142143 if self .INCLUDE is None :
143144 return lambda x : True
144145 return _split_pattern (self .INCLUDE , self .paths )
@@ -172,12 +173,12 @@ def test_all(self) -> None:
172173 self .fail ('\n ' .join (errors ))
173174
174175 @functools .cached_property
175- def paths (self ) -> t . List [str ]:
176+ def paths (self ) -> list [str ]:
176177 return _split_colon (self .PATHS or path_to_import (os .getcwd ())[0 ])
177178
178- def impall (self ) -> t . Tuple [ t . List [str ], t . List [ t . Tuple [str , str ]]]:
179- successes : t . List [str ] = []
180- failures : t . List [ t . Tuple [str , str ]] = []
179+ def impall (self ) -> tuple [ list [str ], list [ tuple [str , str ]]]:
180+ successes : list [str ] = []
181+ failures : list [ tuple [str , str ]] = []
181182
182183 warnings .simplefilter (self .WARNINGS_ACTION )
183184 for file in self ._all_imports (self .paths ):
@@ -186,7 +187,7 @@ def impall(self) -> t.Tuple[t.List[str], t.List[t.Tuple[str, str]]]:
186187 warnings .filters .pop (0 ) # type: ignore[attr-defined]
187188 return successes , failures
188189
189- def _all_imports (self , paths : t . Sequence [str ]) -> t . Iterator [str ]:
190+ def _all_imports (self , paths : Sequence [str ]) -> Iterator [str ]:
190191 for path in paths :
191192 for directory , sub_dirs , files in os .walk (path ):
192193 if directory != path and not self ._accept_dir (directory ):
@@ -203,8 +204,8 @@ def _all_imports(self, paths: t.Sequence[str]) -> t.Iterator[str]:
203204 def _import (
204205 self ,
205206 file : str ,
206- successes : t . List [str ],
207- failures : t . List [ t . Tuple [str , str ]],
207+ successes : list [str ],
208+ failures : list [ tuple [str , str ]],
208209 ) -> None :
209210 root , module = path_to_import (file )
210211 path = file [:- 3 ] if file .endswith ('.py' ) else file
@@ -244,7 +245,7 @@ def _accept_dir(self, directory: str) -> bool:
244245
245246
246247@functools .lru_cache
247- def path_to_import (path : str ) -> t . Tuple [str , str ]:
248+ def path_to_import (path : str ) -> tuple [str , str ]:
248249 """
249250 Return a (path, module) pair that allows you to import the Python file or
250251 directory at location path
@@ -309,17 +310,15 @@ def _is_python_dir(path: str) -> bool:
309310 return os .path .exists (init ) and not _is_ignored (path )
310311
311312
312- def _split_colon (s : t . Union [ str , t . Sequence [str ]] ) -> t . List [str ]:
313+ def _split_colon (s : str | Sequence [str ]) -> list [str ]:
313314 if not s :
314315 return []
315316 if isinstance (s , str ):
316317 return s .split (':' )
317318 return list (s )
318319
319320
320- def _split_pattern (
321- s : t .Union [str , t .Sequence [str ]], paths : t .List [str ]
322- ) -> t .Callable [[str ], bool ]:
321+ def _split_pattern (s : str | Sequence [str ], paths : list [str ]) -> Callable [[str ], bool ]:
323322 def matches (x : str , p : str ) -> bool :
324323 parts = p .split ('.' )
325324 if all (s .isidentifier () for s in parts ):
@@ -361,7 +360,7 @@ def report() -> None:
361360def _parse_args () -> argparse .Namespace :
362361 parser = argparse .ArgumentParser (description = _USAGE )
363362 parser .add_argument ('paths' , nargs = '*' , default = [os .getcwd ()])
364- kwds : t . Dict [str , t . Any ]
363+ kwds : dict [str , Any ]
365364
366365 for prop in PROPERTIES :
367366 default = getattr (ImpAllTest , prop )
0 commit comments