Skip to content

Commit

Permalink
pyright + windows test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayulockin committed Dec 7, 2024
1 parent ee56e8a commit b3ebb1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/ragas/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import json
import os
from abc import ABC, abstractmethod
from typing import Optional
from typing import Any, Optional

from pydantic import BaseModel


class CacheInterface(ABC):
@abstractmethod
def get(self, key: str):
def get(self, key: str) -> Any:
pass

@abstractmethod
def set(self, key: str, value):
def set(self, key: str, value) -> None:
pass

@abstractmethod
Expand All @@ -34,10 +34,10 @@ def __init__(self, cache_dir: str):

self.cache = Cache(cache_dir)

def get(self, key: str):
def get(self, key: str) -> Any:
return self.cache.get(key)

def set(self, key: str, value):
def set(self, key: str, value) -> None:
self.cache.set(key, value)

def has_key(self, key: str) -> bool:
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ def add(x, y):
# We'll simulate side effects by returning a changing result.
@cacher(cache_backend=cache_backend)
def changing_result():
from time import time
import time

return time() # Returns current time, should differ if not cached
time.sleep(0.01) # Sleep to ensure a measurable time difference
return time.time() # Returns current time, should differ if not cached

r1 = changing_result()
r2 = changing_result()
Expand Down

0 comments on commit b3ebb1f

Please sign in to comment.