Skip to content

Commit

Permalink
chore: fix a lot of typos
Browse files Browse the repository at this point in the history
  • Loading branch information
msiemens committed Feb 15, 2022
1 parent f03bdf7 commit 3d74d72
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion tests/test_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ def test_caching_json_write(tmpdir):

del db

# Repoen database
# Reopen database
with TinyDB(path, storage=CachingMiddleware(JSONStorage)) as db:
assert db.all() == [{'key': 'value'}]
2 changes: 1 addition & 1 deletion tests/test_tinydb.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __len__(self):
assert db.count(where('int') == 1) == 1


def test_cutom_mapping_type_with_json(tmpdir):
def test_custom_mapping_type_with_json(tmpdir):
class CustomDocument(Mapping):
def __init__(self, data):
self.data = data
Expand Down
10 changes: 5 additions & 5 deletions tinydb/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .utils import with_typehint

# The table's base class. This is used to add type hinting from the Table
# class to TinyDB. Currently this supports PyCharm, Pyright/VS Code and MyPy.
# class to TinyDB. Currently, this supports PyCharm, Pyright/VS Code and MyPy.
TableBase: Type[Table] = with_typehint(Table)


Expand Down Expand Up @@ -116,7 +116,7 @@ def table(self, name: str, **kwargs) -> Table:
created using the :attr:`~tinydb.database.TinyDB.table_class` class.
Otherwise, the previously created table instance wil be returned.
All futher options besides the name are passed to the table class which
All further options besides the name are passed to the table class which
by default is :class:`~tinydb.table.Table`. Check its documentation
for further parameters you can pass.
Expand Down Expand Up @@ -154,7 +154,7 @@ def tables(self) -> Set[str]:
# To get a set of table names, we thus construct a set of this main
# dict which returns a set of the dict keys which are the table names.
#
# Storage.read() may return ``None`` if the database file is empty
# Storage.read() may return ``None`` if the database file is empty,
# so we need to consider this case to and return an empty set in this
# case.

Expand All @@ -169,7 +169,7 @@ def drop_tables(self) -> None:
# to the storage thereby returning to the initial state with no tables.
self.storage.write({})

# After that we need to remeber to empty the ``_tables`` dict so we'll
# After that we need to remember to empty the ``_tables`` dict, so we'll
# create new table instances when a table is accessed again.
self._tables.clear()

Expand Down Expand Up @@ -269,6 +269,6 @@ def __len__(self):

def __iter__(self) -> Iterator[Document]:
"""
Return an iterater for the default table's documents.
Return an iterator for the default table's documents.
"""
return iter(self.table(self.default_table_name))
6 changes: 3 additions & 3 deletions tinydb/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def __call__(self, *args, **kwargs):
be the storage (or Middleware) instance. Returning the instance is
simple, but we also got the underlying (*real*) StorageClass as an
__init__ argument that still is not an instance.
So, we initialize it in __call__ forwarding any arguments we recieve
So, we initialize it in __call__ forwarding any arguments we receive
from TinyDB (``TinyDB(arg1, kwarg1=value, storage=...)``).
In case of nested Middlewares, calling the instance as if it was an
In case of nested Middlewares, calling the instance as if it was a
class results in calling ``__call__`` what initializes the next
nested Middleware that itself will initialize the next Middleware and
so on.
Expand All @@ -63,7 +63,7 @@ class results in calling ``__call__`` what initializes the next

def __getattr__(self, name):
"""
Forward all unknown attribute calls to the underlying storage so we
Forward all unknown attribute calls to the underlying storage, so we
remain as transparent as possible.
"""

Expand Down
10 changes: 5 additions & 5 deletions tinydb/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def __call__(self, value: Mapping) -> bool:

def __hash__(self):
# We calculate the query hash by using the ``hashval`` object which
# describes this query uniquely so we can calculate a stable hash value
# by simply hashing it
# describes this query uniquely, so we can calculate a stable hash
# value by simply hashing it
return hash(self._hash)

def __repr__(self):
Expand Down Expand Up @@ -137,7 +137,7 @@ class Query(QueryInstance):
"""
TinyDB Queries.
Allows to build queries for TinyDB databases. There are two main ways of
Allows building queries for TinyDB databases. There are two main ways of
using queries:
1) ORM-like usage:
Expand All @@ -163,7 +163,7 @@ class Query(QueryInstance):
Queries are executed by calling the resulting object. They expect to get
the document to test as the first argument and return ``True`` or
``False`` depending on whether the documents matches the query or not.
``False`` depending on whether the documents match the query or not.
"""

def __init__(self) -> None:
Expand Down Expand Up @@ -513,7 +513,7 @@ def map(self, fn: Callable[[Any], Any]) -> 'Query':
# Now we add the callable to the query path ...
query._path = self._path + (fn,)

# ... and kill the hash - callable objects can be mutable so it's
# ... and kill the hash - callable objects can be mutable, so it's
# harmful to cache their results.
query._hash = None

Expand Down
4 changes: 2 additions & 2 deletions tinydb/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def read(self) -> Optional[Dict[str, Dict[str, Any]]]:
size = self._handle.tell()

if not size:
# File is empty so we return ``None`` so TinyDB can properly
# File is empty, so we return ``None`` so TinyDB can properly
# initialize the database
return None
else:
Expand All @@ -137,7 +137,7 @@ def write(self, data: Dict[str, Dict[str, Any]]):
except io.UnsupportedOperation:
raise IOError('Cannot write to the database. Access mode is "{0}"'.format(self._mode))

# Ensure the file has been writtens
# Ensure the file has been written
self._handle.flush()
os.fsync(self._handle.fileno())

Expand Down
12 changes: 6 additions & 6 deletions tinydb/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Document(dict):
"""
A document stored in the database.
This class provides a way to access both a document's content as well as
This class provides a way to access both a document's content and
its ID using ``doc.doc_id``.
"""

Expand Down Expand Up @@ -178,7 +178,7 @@ def insert_multiple(self, documents: Iterable[Mapping]) -> List[int]:
"""
Insert multiple documents into the table.
:param documents: a Iterable of documents to insert
:param documents: an Iterable of documents to insert
:returns: a list containing the inserted documents' IDs
"""
doc_ids = []
Expand Down Expand Up @@ -545,8 +545,8 @@ def remove(
# been removed. When removing documents identified by a set of
# document IDs, it's this list of document IDs we need to return
# later.
# We convert the document ID iterator into a list so we can both
# use the document IDs to remove the specified documents as well as
# We convert the document ID iterator into a list, so we can both
# use the document IDs to remove the specified documents and
# to return the list of affected document IDs
removed_ids = list(doc_ids)

Expand Down Expand Up @@ -699,10 +699,10 @@ def _read_table(self) -> Dict[str, Mapping]:

def _update_table(self, updater: Callable[[Dict[int, Mapping]], None]):
"""
Perform an table update operation.
Perform a table update operation.
The storage interface used by TinyDB only allows to read/write the
complete database data, but not modifying only portions of it. Thus
complete database data, but not modifying only portions of it. Thus,
to only update portions of the table data, we first perform a read
operation, perform the update on the table data and then write
the updated data back to the storage.
Expand Down

0 comments on commit 3d74d72

Please sign in to comment.