Skip to content

Commit

Permalink
Type hint ODL importer classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Sep 22, 2023
1 parent 7993f30 commit 745b4b5
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 131 deletions.
2 changes: 1 addition & 1 deletion api/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def __init__(
identifier_type: Optional[str],
identifier: Optional[str],
start_date: Optional[datetime.datetime],
end_date: datetime.datetime,
end_date: Optional[datetime.datetime],
fulfillment_info: Optional[FulfillmentInfo] = None,
external_identifier: Optional[str] = None,
locked_to: Optional[DeliveryMechanismInfo] = None,
Expand Down
13 changes: 6 additions & 7 deletions api/lcp/hash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hashlib
from abc import ABCMeta, abstractmethod
from abc import ABC, abstractmethod
from enum import Enum

from core.exceptions import BaseError
Expand All @@ -14,20 +14,19 @@ class HashingError(BaseError):
"""Raised in the case of errors occurred during hashing"""


class Hasher(metaclass=ABCMeta):
class Hasher(ABC):
"""Base class for all implementations of different hashing algorithms"""

def __init__(self, hashing_algorithm):
def __init__(self, hashing_algorithm: HashingAlgorithm) -> None:
"""Initializes a new instance of Hasher class
:param hashing_algorithm: Hashing algorithm
:type hashing_algorithm: HashingAlgorithm
"""
self._hashing_algorithm = hashing_algorithm

@abstractmethod
def hash(self, value):
raise NotImplementedError()
def hash(self, value: str) -> str:
...


class UniversalHasher(Hasher):
Expand All @@ -49,5 +48,5 @@ def hash(self, value: str) -> str:


class HasherFactory:
def create(self, hashing_algorithm):
def create(self, hashing_algorithm: HashingAlgorithm) -> Hasher:
return UniversalHasher(hashing_algorithm)
Loading

0 comments on commit 745b4b5

Please sign in to comment.