Skip to content

wrap_kvs inconsistencies (due to incorrect signature-based conditioning) #9

@thorwhalen

Description

@thorwhalen

And example of the problem with wrap_kvs(...obj_of_data).

from dol import Files, wrap_kvs

s = wrap_kvs(
     Files(rootdir), 
     obj_of_data=lambda x: bytes.decode(x)
)

s.head()  # works fine (as long as the first item's bytes can be decoded (as text)

But, though bytes.decode is "equivalent" to lambda x: bytes.decode(x), the following doesn't work:

from dol import Files, wrap_kvs

s = wrap_kvs(
     Files(rootdir), 
     obj_of_data=bytes.decode,
)

s.head() 

Instead we get:

TypeError: descriptor 'decode' for 'bytes' objects doesn't apply to a 'Store' object

The reason is that there's some dark (and apparently bad) magic happening behind the scenes.
Probably something that checks the signature of obj_of_data and does something (not so) "smart" about how it applies the function.

┆Issue is synchronized with this Asana task by Unito

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions