From eecc035f4c2ed69cf9dbceae009c583d849b9f2c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 2 Feb 2023 11:27:40 -0800 Subject: [PATCH] correcting type hints --- scrapy/pipelines/files.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scrapy/pipelines/files.py b/scrapy/pipelines/files.py index 1b724ce60..fcd9f9078 100644 --- a/scrapy/pipelines/files.py +++ b/scrapy/pipelines/files.py @@ -9,11 +9,11 @@ import logging import mimetypes import os import time -from os import PathLike from collections import defaultdict from contextlib import suppress from ftplib import FTP from io import BytesIO +from os import PathLike from pathlib import Path from typing import DefaultDict, Optional, Set, Union from urllib.parse import urlparse @@ -54,12 +54,14 @@ class FSFilesStore: self._mkdir(Path(self.basedir)) self.created_directories: DefaultDict[str, Set[str]] = defaultdict(set) - def persist_file(self, path: str, buf, info, meta=None, headers=None): + def persist_file( + self, path: Union[str, PathLike], buf, info, meta=None, headers=None + ): absolute_path = self._get_filesystem_path(path) self._mkdir(absolute_path.parent, info) absolute_path.write_bytes(buf.getvalue()) - def stat_file(self, path: str, info): + def stat_file(self, path: Union[str, PathLike], info): absolute_path = self._get_filesystem_path(path) try: last_modified = absolute_path.stat().st_mtime