55import  os 
66import  re 
77import  sys 
8+ import  types 
89import  typing  as  ty 
910
1011from  . import  utils 
@@ -511,7 +512,7 @@ def __init__(
511512			# 
512513			# Note: `os.fwalk` support for binary paths was only added in 3.7+. 
513514			directory_str_or_fd  =  directory_str   # type: ty.Union[ty.AnyStr, int] 
514- 			if  HAVE_FWALK  and  (not  isinstance (directory_str , bytes ) or  HAVE_FWALK_BYTES ):
515+ 			if  HAVE_FWALK  and  (not  isinstance (directory_str , bytes ) or  HAVE_FWALK_BYTES ):   # type: ignore[unreachable]  # noqa: E501 
515516				self ._close_fd  =  directory_str_or_fd  =  os .open (directory_str , os .O_RDONLY  |  O_DIRECTORY )
516517
517518			self ._generator  =  self ._walk (
@@ -533,10 +534,24 @@ def __exit__(self, *a: ty.Any) -> None:
533534	def  send (self , value : ty .Any ) ->  FSNodeEntry :
534535		return  self ._generator .send (value )
535536
536- 	def  throw (self , typ : ty .Type [BaseException ], val : ty .Optional [BaseException ] =  None ,
537- 	          tb : ty .Any  =  None ) ->  FSNodeEntry :
537+ 	@ty .overload  
538+ 	def  throw (self , typ : ty .Type [BaseException ],  # noqa: E704 
539+ 	          val : ty .Union [BaseException , object ] =  ...,
540+ 	          tb : ty .Optional [types .TracebackType ] =  ...) ->  FSNodeEntry : ...
541+ 	
542+ 	@ty .overload  
543+ 	def  throw (self , typ : BaseException , val : None  =  ...,  # noqa: E704 
544+ 	          tb : ty .Optional [types .TracebackType ] =  ...) ->  FSNodeEntry : ...
545+ 	
546+ 	def  throw (self , typ : ty .Union [ty .Type [BaseException ], BaseException ],
547+ 	          val : ty .Union [BaseException , object ] =  None ,
548+ 	          tb : ty .Optional [types .TracebackType ] =  None ) ->  FSNodeEntry :
538549		try :
539- 			return  self ._generator .throw (typ , val , tb )
550+ 			if  isinstance (typ , type ):
551+ 				return  self ._generator .throw (typ , val , tb )
552+ 			else :
553+ 				assert  val  is  None 
554+ 				return  self ._generator .throw (typ , val , tb )
540555		except :
541556			if  self ._close_fd  is  not   None :
542557				os .close (self ._close_fd )
0 commit comments