Skip to content

Commit

Permalink
Add type hints (scrapy#6191)
Browse files Browse the repository at this point in the history
  • Loading branch information
y26805 authored Dec 29, 2023
1 parent 1902284 commit 40e623b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion scrapy/pipelines/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ class FilesPipeline(MediaPipeline):
DEFAULT_FILES_URLS_FIELD = "file_urls"
DEFAULT_FILES_RESULT_FIELD = "files"

def __init__(self, store_uri, download_func=None, settings=None):
def __init__(
self, store_uri: Union[str, PathLike], download_func=None, settings=None
):
store_uri = _to_string(store_uri)
if not store_uri:
raise NotConfigured
Expand Down
7 changes: 5 additions & 2 deletions scrapy/pipelines/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import warnings
from contextlib import suppress
from io import BytesIO
from typing import Dict, Tuple
from os import PathLike
from typing import Dict, Tuple, Union

from itemadapter import ItemAdapter

Expand Down Expand Up @@ -53,7 +54,9 @@ class ImagesPipeline(FilesPipeline):
DEFAULT_IMAGES_URLS_FIELD = "image_urls"
DEFAULT_IMAGES_RESULT_FIELD = "images"

def __init__(self, store_uri, download_func=None, settings=None):
def __init__(
self, store_uri: Union[str, PathLike], download_func=None, settings=None
):
try:
from PIL import Image

Expand Down

0 comments on commit 40e623b

Please sign in to comment.