Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update __init__.py - use of None in mapper parameter #4

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def parse(fp, mapper=dict, merge_duplicate_keys=True, escaped=True):
same key into one instead of overwriting. You can se this to ``False`` if you are
using ``VDFDict`` and need to preserve the duplicates.
"""
mapper = dict if mapper is None else mapper
if not issubclass(mapper, Mapping):
raise TypeError("Expected mapper to be subclass of dict, got %s" % type(mapper))
if not hasattr(fp, 'readline'):
Expand Down Expand Up @@ -298,6 +299,7 @@ def binary_loads(b, mapper=dict, merge_duplicate_keys=True, alt_format=False, ke
table. Newer `appinfo.vdf` format stores this table the end of the file,
and it is needed to deserialize the binary VDF objects in that file.
"""
mapper = dict if mapper is None else mapper
if not isinstance(b, bytes):
raise TypeError("Expected s to be bytes, got %s" % type(b))

Expand Down