fixed mypy warnings with type declaration for os.PathLike

This commit is contained in:
Alex 2023-01-24 22:57:25 -08:00
parent 84fb234cae
commit 44512bebc8
1 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ from scrapy.utils.request import referer_str
logger = logging.getLogger(__name__)
def _to_string(path: Union[str, os.PathLike]):
def _to_string(path: Union[str, os.PathLike[str]]):
return str(path) # convert a Path object to string
@ -45,7 +45,7 @@ class FileException(Exception):
class FSFilesStore:
def __init__(self, basedir: Union[str, os.PathLike]):
def __init__(self, basedir: Union[str, os.PathLike[str]]):
basedir = _to_string(basedir)
if '://' in basedir:
basedir = basedir.split('://', 1)[1]
@ -70,7 +70,7 @@ class FSFilesStore:
return {'last_modified': last_modified, 'checksum': checksum}
def _get_filesystem_path(self, path: Union[str, os.PathLike]) -> Path:
def _get_filesystem_path(self, path: Union[str, os.PathLike[str]]) -> Path:
path_comps = _to_string(path).split('/')
return Path(self.basedir, *path_comps)