mirror of
https://github.com/enpaul/kodak.git
synced 2025-11-09 20:22:31 +00:00
Fix typing errors
Fix missing dependencies in static tox envs
This commit is contained in:
@@ -136,7 +136,7 @@ class ManipCropConfig:
|
||||
def from_env(cls, key: str):
|
||||
"""Build dataclass from environment"""
|
||||
return cls(
|
||||
anchor=_get_enum_by_value(
|
||||
anchor=_get_enum_by_value( # type: ignore
|
||||
f"KODAK_MANIP_{key}_CROP_ANCHOR", constants.CropAnchor, cls.anchor
|
||||
),
|
||||
horizontal=_get_int(f"KODAK_MANIP_{key}_CROP_HORIZONTAL", cls.horizontal),
|
||||
@@ -173,16 +173,16 @@ class ManipScaleConfig:
|
||||
)
|
||||
|
||||
if strategy == constants.ScaleStrategy.ABSOLUTE:
|
||||
parser = _get_int
|
||||
parser = _get_int # type: ignore
|
||||
elif strategy == constants.ScaleStrategy.RELATIVE:
|
||||
parser = _get_float
|
||||
parser = _get_float # type: ignore
|
||||
else:
|
||||
raise RuntimeError("This path should not be possible")
|
||||
|
||||
return cls(
|
||||
strategy=strategy,
|
||||
vertical=parser(f"KODAK_MANIP_{key}_SCALE_VERTICAL", cls.vertical),
|
||||
horizontal=parser(f"KODAK_MANIP_{key}_SCALE_HORIZONTAL", cls.horizontal),
|
||||
strategy=strategy, # type: ignore
|
||||
vertical=parser(f"KODAK_MANIP_{key}_SCALE_VERTICAL", cls.vertical), # type: ignore
|
||||
horizontal=parser(f"KODAK_MANIP_{key}_SCALE_HORIZONTAL", cls.horizontal), # type: ignore
|
||||
)
|
||||
|
||||
|
||||
@@ -198,8 +198,8 @@ class ManipConfig:
|
||||
"""
|
||||
|
||||
name: str
|
||||
crop: ManipCropConfig = field(default_factory=ManipCropConfig.from_env)
|
||||
scale: ManipScaleConfig = field(default_factory=ManipScaleConfig.from_env)
|
||||
crop: ManipCropConfig = field(default_factory=ManipCropConfig)
|
||||
scale: ManipScaleConfig = field(default_factory=ManipScaleConfig)
|
||||
formats: Set[constants.ImageFormat] = field(
|
||||
default_factory=lambda: constants.DEFAULT_SUPPORTED_FORMATS
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
from typing import Tuple
|
||||
from typing import Type
|
||||
|
||||
import peewee
|
||||
|
||||
@@ -13,7 +14,7 @@ from kodak.database.alias import AliasRecord
|
||||
from kodak.database.image import ImageRecord
|
||||
|
||||
|
||||
MODELS: Tuple[KodakModel, ...] = (ImageRecord, AliasRecord, AccessRecord)
|
||||
MODELS: Tuple[Type[KodakModel], ...] = (ImageRecord, AliasRecord, AccessRecord)
|
||||
|
||||
|
||||
def initialize(config: KodakConfig):
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import datetime
|
||||
import enum
|
||||
import hashlib
|
||||
import typing
|
||||
import uuid
|
||||
from typing import NamedTuple
|
||||
from typing import Type
|
||||
|
||||
import peewee
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
import _hashlib
|
||||
|
||||
|
||||
INTERFACE = peewee.DatabaseProxy()
|
||||
|
||||
@@ -22,7 +25,7 @@ class Checksum(NamedTuple):
|
||||
digest: str
|
||||
|
||||
@classmethod
|
||||
def from_hash(cls, data: hashlib._hashlib.HASH): # pylint: disable=protected-access
|
||||
def from_hash(cls, data: "_hashlib.HASH"):
|
||||
"""Construct from a hashlib object"""
|
||||
return cls(algorithm=data.name, digest=data.hexdigest())
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ class ImageResourceDeletedError(ClientError):
|
||||
status = 410
|
||||
|
||||
|
||||
class IAmATeapotError(ClientError):
|
||||
"""User tried to brew coffee, but application is a teapot"""
|
||||
|
||||
status = 418
|
||||
|
||||
|
||||
class ServerError(KodakException):
|
||||
"""Error while processing server side data"""
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Tuple
|
||||
from typing import Type
|
||||
|
||||
from kodak.resources._shared import KodakResource
|
||||
from kodak.resources.alias import ImageAlias
|
||||
@@ -7,7 +8,7 @@ from kodak.resources.image import Image
|
||||
from kodak.resources.openapi import OpenAPI
|
||||
|
||||
|
||||
RESOURCES: Tuple[KodakResource, ...] = (
|
||||
RESOURCES: Tuple[Type[KodakResource], ...] = (
|
||||
Heartbeat,
|
||||
Image,
|
||||
ImageAlias,
|
||||
|
||||
Reference in New Issue
Block a user