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

Restrict possible return types of _put and _delete methods #28

Open
mlondschien opened this issue Apr 26, 2021 · 4 comments
Open

Restrict possible return types of _put and _delete methods #28

mlondschien opened this issue Apr 26, 2021 · 4 comments

Comments

@mlondschien
Copy link
Member

I forgot: Do we (want to) restrict the return types of _put and _delete methods implemented by the backends? IIUC they generally return the key at which data was saved (or deleted).

Originally posted by @mlondschien in #25 (comment)

@xhochy
Copy link
Member

xhochy commented Apr 26, 2021

👍 sounds like we should do that and verify that all backends do that (should be through mypy's checks already then).

@mlondschien
Copy link
Member Author

mypy cannot check as many of the underlying modules are not typed sadly.

@mlondschien
Copy link
Member Author

mlondschien commented Apr 29, 2021

This

assert isinstance(key, str)

could test

        new_key = store.put(key, value)
        assert new_key == key

We could do the same for delete, move and copy.

@mlondschien
Copy link
Member Author

delete

Most backends return None, except for

mongo, which returns a pymongo.results.DeleteResult:

def _delete(self, key: str) -> str:
return self.db[self.collection].delete_one({"_id": key})

redis, which returns 1 if a file was deleted and 0 else:
def _delete(self, key: str) -> int:
return self.redis.delete(key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants