|
28 | 28 | try: |
29 | 29 | from scandir import scandir # type: ignore |
30 | 30 | except ImportError: # pragma: no cover |
31 | | - scandir = None # pragma: no cover |
| 31 | + scandir = None # type: ignore # pragma: no cover |
32 | 32 |
|
33 | 33 | try: |
34 | 34 | from os import sendfile |
35 | 35 | except ImportError: |
36 | 36 | try: |
37 | 37 | from sendfile import sendfile # type: ignore |
38 | 38 | except ImportError: |
39 | | - sendfile = None # pragma: no cover |
| 39 | + sendfile = None # type: ignore # pragma: no cover |
40 | 40 |
|
41 | 41 | from . import errors |
42 | 42 | from .errors import FileExists |
@@ -186,7 +186,7 @@ def __str__(self): |
186 | 186 | return fmt.format(_class_name.lower(), self.root_path) |
187 | 187 |
|
188 | 188 | def _to_sys_path(self, path): |
189 | | - # type: (Text) -> Text |
| 189 | + # type: (Text) -> bytes |
190 | 190 | """Convert a FS path to a path on the OS. |
191 | 191 | """ |
192 | 192 | sys_path = fsencode( |
@@ -266,13 +266,11 @@ def _gettarget(self, sys_path): |
266 | 266 | if hasattr(os, "readlink"): |
267 | 267 | try: |
268 | 268 | if _WINDOWS_PLATFORM: # pragma: no cover |
269 | | - target = os.readlink(sys_path) |
| 269 | + return os.readlink(sys_path) |
270 | 270 | else: |
271 | | - target = os.readlink(fsencode(sys_path)) |
| 271 | + return fsdecode(os.readlink(fsencode(sys_path))) |
272 | 272 | except OSError: |
273 | 273 | pass |
274 | | - else: |
275 | | - return target |
276 | 274 | return None |
277 | 275 |
|
278 | 276 | def _make_link_info(self, sys_path): |
@@ -484,7 +482,7 @@ def _scandir(self, path, namespaces=None): |
484 | 482 | self._root_path, path.lstrip("/").replace("/", os.sep) |
485 | 483 | ) |
486 | 484 | else: |
487 | | - sys_path = self._to_sys_path(_path) |
| 485 | + sys_path = self._to_sys_path(_path) # type: ignore |
488 | 486 | with convert_os_errors("scandir", path, directory=True): |
489 | 487 | for dir_entry in scandir(sys_path): |
490 | 488 | info = { |
|
0 commit comments