2222from  io  import  StringIO 
2323from  itertools  import  chain 
2424from  pathlib  import  Path 
25- from  typing  import  Any , Optional ,  TextIO ,  Union , cast 
25+ from  typing  import  Any , TextIO , cast 
2626from  warnings  import  warn 
2727
2828from  isort  import  core 
@@ -69,11 +69,11 @@ class ImportKey(Enum):
6969
7070def  sort_code_string (
7171    code : str ,
72-     extension : Optional [ str ]  =  None ,
72+     extension : str   |   None  =  None ,
7373    config : Config  =  DEFAULT_CONFIG ,
74-     file_path : Optional [ Path ]  =  None ,
74+     file_path : Path   |   None  =  None ,
7575    disregard_skip : bool  =  False ,
76-     show_diff : Union [ bool ,  TextIO ]  =  False ,
76+     show_diff : bool   |   TextIO  =  False ,
7777    ** config_kwargs : Any ,
7878) ->  str :
7979    """Sorts any imports within the provided code string, returning a new string with them sorted. 
@@ -105,10 +105,10 @@ def sort_code_string(
105105
106106def  check_code_string (
107107    code : str ,
108-     show_diff : Union [ bool ,  TextIO ]  =  False ,
109-     extension : Optional [ str ]  =  None ,
108+     show_diff : bool   |   TextIO  =  False ,
109+     extension : str   |   None  =  None ,
110110    config : Config  =  DEFAULT_CONFIG ,
111-     file_path : Optional [ Path ]  =  None ,
111+     file_path : Path   |   None  =  None ,
112112    disregard_skip : bool  =  False ,
113113    ** config_kwargs : Any ,
114114) ->  bool :
@@ -138,11 +138,11 @@ def check_code_string(
138138def  sort_stream (
139139    input_stream : TextIO ,
140140    output_stream : TextIO ,
141-     extension : Optional [ str ]  =  None ,
141+     extension : str   |   None  =  None ,
142142    config : Config  =  DEFAULT_CONFIG ,
143-     file_path : Optional [ Path ]  =  None ,
143+     file_path : Path   |   None  =  None ,
144144    disregard_skip : bool  =  False ,
145-     show_diff : Union [ bool ,  TextIO ]  =  False ,
145+     show_diff : bool   |   TextIO  =  False ,
146146    raise_on_skip : bool  =  True ,
147147    ** config_kwargs : Any ,
148148) ->  bool :
@@ -240,10 +240,10 @@ def sort_stream(
240240
241241def  check_stream (
242242    input_stream : TextIO ,
243-     show_diff : Union [ bool ,  TextIO ]  =  False ,
244-     extension : Optional [ str ]  =  None ,
243+     show_diff : bool   |   TextIO  =  False ,
244+     extension : str   |   None  =  None ,
245245    config : Config  =  DEFAULT_CONFIG ,
246-     file_path : Optional [ Path ]  =  None ,
246+     file_path : Path   |   None  =  None ,
247247    disregard_skip : bool  =  False ,
248248    ** config_kwargs : Any ,
249249) ->  bool :
@@ -306,12 +306,12 @@ def check_stream(
306306
307307
308308def  check_file (
309-     filename : Union [ str ,  Path ] ,
310-     show_diff : Union [ bool ,  TextIO ]  =  False ,
309+     filename : str   |   Path ,
310+     show_diff : bool   |   TextIO  =  False ,
311311    config : Config  =  DEFAULT_CONFIG ,
312-     file_path : Optional [ Path ]  =  None ,
312+     file_path : Path   |   None  =  None ,
313313    disregard_skip : bool  =  True ,
314-     extension : Optional [ str ]  =  None ,
314+     extension : str   |   None  =  None ,
315315    ** config_kwargs : Any ,
316316) ->  bool :
317317    """Checks any imports within the provided file, returning `False` if any unsorted or 
@@ -359,7 +359,7 @@ def _in_memory_output_stream_context() -> Iterator[TextIO]:
359359
360360
361361@contextlib .contextmanager  
362- def  _file_output_stream_context (filename : Union [ str ,  Path ] , source_file : File ) ->  Iterator [TextIO ]:
362+ def  _file_output_stream_context (filename : str   |   Path , source_file : File ) ->  Iterator [TextIO ]:
363363    tmp_file  =  _tmp_file (source_file )
364364    with  tmp_file .open ("w+" , encoding = source_file .encoding , newline = "" ) as  output_stream :
365365        shutil .copymode (filename , tmp_file )
@@ -370,15 +370,15 @@ def _file_output_stream_context(filename: Union[str, Path], source_file: File) -
370370# the main entrypoints so sort of expected to be complex. 
371371# skipcq: PY-R1000 
372372def  sort_file (
373-     filename : Union [ str ,  Path ] ,
374-     extension : Optional [ str ]  =  None ,
373+     filename : str   |   Path ,
374+     extension : str   |   None  =  None ,
375375    config : Config  =  DEFAULT_CONFIG ,
376-     file_path : Optional [ Path ]  =  None ,
376+     file_path : Path   |   None  =  None ,
377377    disregard_skip : bool  =  True ,
378378    ask_to_apply : bool  =  False ,
379-     show_diff : Union [ bool ,  TextIO ]  =  False ,
379+     show_diff : bool   |   TextIO  =  False ,
380380    write_to_stdout : bool  =  False ,
381-     output : Optional [ TextIO ]  =  None ,
381+     output : TextIO   |   None  =  None ,
382382    ** config_kwargs : Any ,
383383) ->  bool :
384384    """Sorts and formats any groups of imports within the provided file or Path. 
@@ -510,8 +510,8 @@ def sort_file(
510510def  find_imports_in_code (
511511    code : str ,
512512    config : Config  =  DEFAULT_CONFIG ,
513-     file_path : Optional [ Path ]  =  None ,
514-     unique : Union [ bool ,  ImportKey ]  =  False ,
513+     file_path : Path   |   None  =  None ,
514+     unique : bool   |   ImportKey  =  False ,
515515    top_only : bool  =  False ,
516516    ** config_kwargs : Any ,
517517) ->  Iterator [identify .Import ]:
@@ -537,10 +537,10 @@ def find_imports_in_code(
537537def  find_imports_in_stream (
538538    input_stream : TextIO ,
539539    config : Config  =  DEFAULT_CONFIG ,
540-     file_path : Optional [ Path ]  =  None ,
541-     unique : Union [ bool ,  ImportKey ]  =  False ,
540+     file_path : Path   |   None  =  None ,
541+     unique : bool   |   ImportKey  =  False ,
542542    top_only : bool  =  False ,
543-     _seen : Optional [ set [str ]]  =  None ,
543+     _seen : set [str ]  |   None  =  None ,
544544    ** config_kwargs : Any ,
545545) ->  Iterator [identify .Import ]:
546546    """Finds and returns all imports within the provided code stream. 
@@ -577,10 +577,10 @@ def find_imports_in_stream(
577577
578578
579579def  find_imports_in_file (
580-     filename : Union [ str ,  Path ] ,
580+     filename : str   |   Path ,
581581    config : Config  =  DEFAULT_CONFIG ,
582-     file_path : Optional [ Path ]  =  None ,
583-     unique : Union [ bool ,  ImportKey ]  =  False ,
582+     file_path : Path   |   None  =  None ,
583+     unique : bool   |   ImportKey  =  False ,
584584    top_only : bool  =  False ,
585585    ** config_kwargs : Any ,
586586) ->  Iterator [identify .Import ]:
@@ -609,10 +609,10 @@ def find_imports_in_file(
609609
610610
611611def  find_imports_in_paths (
612-     paths : Iterator [Union [ str ,  Path ] ],
612+     paths : Iterator [str   |   Path ],
613613    config : Config  =  DEFAULT_CONFIG ,
614-     file_path : Optional [ Path ]  =  None ,
615-     unique : Union [ bool ,  ImportKey ]  =  False ,
614+     file_path : Path   |   None  =  None ,
615+     unique : bool   |   ImportKey  =  False ,
616616    top_only : bool  =  False ,
617617    ** config_kwargs : Any ,
618618) ->  Iterator [identify .Import ]:
@@ -627,7 +627,7 @@ def find_imports_in_paths(
627627    - ****config_kwargs**: Any config modifications. 
628628    """ 
629629    config  =  _config (config = config , ** config_kwargs )
630-     seen : Optional [ set [str ]]  =  set () if  unique  else  None 
630+     seen : set [str ]  |   None  =  set () if  unique  else  None 
631631    yield  from  chain (
632632        * (
633633            find_imports_in_file (
@@ -639,7 +639,7 @@ def find_imports_in_paths(
639639
640640
641641def  _config (
642-     path : Optional [ Path ]  =  None , config : Config  =  DEFAULT_CONFIG , ** config_kwargs : Any 
642+     path : Path   |   None  =  None , config : Config  =  DEFAULT_CONFIG , ** config_kwargs : Any 
643643) ->  Config :
644644    if  path  and  (
645645        config  is  DEFAULT_CONFIG 
0 commit comments