3333 from os import sendfile
3434except ImportError :
3535 try :
36- from sendfile import sendfile
36+ from sendfile import sendfile # type: ignore
3737 except ImportError :
3838 sendfile = None
3939
@@ -116,7 +116,7 @@ def __init__(
116116 root_path = fsdecode (root_path )
117117 self .root_path = root_path
118118 _drive , _root_path = os .path .splitdrive (fsdecode (fspath (root_path )))
119- _root_path = _drive + (_root_path or '/' ) if _drive else _root_path
119+ _root_path = _drive + (_root_path or "/" ) if _drive else _root_path
120120 _root_path = os .path .expanduser (os .path .expandvars (_root_path ))
121121 _root_path = os .path .normpath (os .path .abspath (_root_path ))
122122 self ._root_path = _root_path
@@ -378,7 +378,6 @@ def opendir(self, path, factory=None):
378378 # type: (_O, Text, Optional[_OpendirFactory]) -> SubFS[_O]
379379 pass
380380
381-
382381 # --- Backport of os.sendfile for Python < 3.8 -----------
383382
384383 def _check_copy (self , src_path , dst_path , overwrite = False ):
@@ -396,31 +395,35 @@ def _check_copy(self, src_path, dst_path, overwrite=False):
396395 raise errors .DirectoryExpected (dirname (dst_path ))
397396 return _src_path , _dst_path
398397
399-
400398 if sys .version_info [:2 ] < (3 , 8 ) and sendfile is not None :
401399
402- _sendfile_error_codes = frozenset ({
403- errno .EIO ,
404- errno .EINVAL ,
405- errno .ENOSYS ,
406- errno .ENOTSUP ,
407- errno .EBADF ,
408- errno .ENOTSOCK ,
409- errno .EOPNOTSUPP ,
410- })
400+ _sendfile_error_codes = frozenset (
401+ {
402+ errno .EIO ,
403+ errno .EINVAL ,
404+ errno .ENOSYS ,
405+ errno .ENOTSUP , # type: ignore
406+ errno .EBADF ,
407+ errno .ENOTSOCK ,
408+ errno .EOPNOTSUPP ,
409+ }
410+ )
411411
412412 def copy (self , src_path , dst_path , overwrite = False ):
413413 # type: (Text, Text, bool) -> None
414414 with self ._lock :
415415 # validate and canonicalise paths
416416 _src_path , _dst_path = self ._check_copy (src_path , dst_path , overwrite )
417- _src_sys , _dst_sys = self .getsyspath (_src_path ), self .getsyspath (_dst_path )
417+ _src_sys , _dst_sys = (
418+ self .getsyspath (_src_path ),
419+ self .getsyspath (_dst_path ),
420+ )
418421 # attempt using sendfile
419422 try :
420423 # initialise variables to pass to sendfile
421424 # open files to obtain a file descriptor
422- with io .open (_src_sys , 'r' ) as src :
423- with io .open (_dst_sys , 'w' ) as dst :
425+ with io .open (_src_sys , "r" ) as src :
426+ with io .open (_dst_sys , "w" ) as dst :
424427 fd_src , fd_dst = src .fileno (), dst .fileno ()
425428 sent = maxsize = os .fstat (fd_src ).st_size
426429 offset = 0
0 commit comments