Skip to content

Commit

Permalink
chore: fix MyPy type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
msiemens committed Nov 26, 2022
1 parent 998fef0 commit cd0b719
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions tinydb/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Contains the :class:`base class <tinydb.middlewares.Middleware>` for
middlewares and implementations.
"""
from typing import Optional

from tinydb import Storage


class Middleware:
Expand All @@ -15,9 +18,9 @@ class Middleware:
constructor so the middleware chain can be configured properly.
"""

def __init__(self, storage_cls):
def __init__(self, storage_cls) -> None:
self._storage_cls = storage_cls
self.storage = None
self.storage: Storage = None # type: ignore

def __call__(self, *args, **kwargs):
"""
Expand Down
6 changes: 3 additions & 3 deletions tinydb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LRUCache(abc.MutableMapping, Generic[K, V]):
be discarded.
"""

def __init__(self, capacity=None):
def __init__(self, capacity=None) -> None:
self.capacity = capacity
self.cache: OrderedDict[K, V] = OrderedDict()

Expand Down Expand Up @@ -87,7 +87,7 @@ def __getitem__(self, key) -> V:
def __iter__(self) -> Iterator[K]:
return iter(self.cache)

def get(self, key: K, default: D = None) -> Optional[Union[V, D]]:
def get(self, key: K, default: Optional[D] = None) -> Optional[Union[V, D]]:
value = self.cache.get(key)

if value is not None:
Expand Down Expand Up @@ -131,7 +131,7 @@ def _immutable(self, *args, **kws):
__setitem__ = _immutable
__delitem__ = _immutable
clear = _immutable
setdefault = _immutable
setdefault = _immutable # type: ignore
popitem = _immutable

def update(self, e=None, **f):
Expand Down

0 comments on commit cd0b719

Please sign in to comment.