Move Size type alias to utils

This commit is contained in:
miruka 2019-11-12 09:26:43 -04:00
parent ef391d1eb1
commit 47bfad1d72
2 changed files with 4 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import io
import re import re
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Any, DefaultDict, Dict, Optional, Tuple from typing import Any, DefaultDict, Dict, Optional
from urllib.parse import urlparse from urllib.parse import urlparse
import aiofiles import aiofiles
@ -13,9 +13,9 @@ from PIL import Image as PILImage
import nio import nio
from .backend import Backend from .backend import Backend
from .utils import Size
CryptDict = Optional[Dict[str, Any]] CryptDict = Optional[Dict[str, Any]]
Size = Tuple[int, int]
CONCURRENT_DOWNLOADS_LIMIT = asyncio.BoundedSemaphore(8) CONCURRENT_DOWNLOADS_LIMIT = asyncio.BoundedSemaphore(8)
ACCESS_LOCKS: DefaultDict[str, asyncio.Lock] = DefaultDict(asyncio.Lock) ACCESS_LOCKS: DefaultDict[str, asyncio.Lock] = DefaultDict(asyncio.Lock)

View File

@ -16,6 +16,7 @@ from typing import IO, Any, Callable, Dict, Tuple, Type, Union
import filetype import filetype
File = Union[IO, bytes, str, Path] File = Union[IO, bytes, str, Path]
Size = Tuple[int, int]
auto = autostr auto = autostr
CANCELLABLE_FUTURES: Dict[Tuple[Any, Callable], asyncio.Future] = {} CANCELLABLE_FUTURES: Dict[Tuple[Any, Callable], asyncio.Future] = {}
@ -59,7 +60,7 @@ def is_svg(file: File) -> bool:
return False return False
def svg_dimensions(file: File) -> Tuple[int, int]: def svg_dimensions(file: File) -> Size:
"""Return the width & height or viewBox width & height for a SVG. """Return the width & height or viewBox width & height for a SVG.
If these properties are missing (broken file), ``(256, 256)`` is returned. If these properties are missing (broken file), ``(256, 256)`` is returned.
""" """