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

Python: adds TYPE command #945

Merged
merged 1 commit into from
Feb 13, 2024
Merged

Conversation

shohamazon
Copy link
Collaborator

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@shohamazon shohamazon requested a review from a team as a code owner February 12, 2024 12:45
key (str): The key to check its data type.

Returns:
Optional[str]: The type of value stored at `key`, or "none" when key doesn't exist.
Copy link
Collaborator

@barshaul barshaul Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "none" => None

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh, I see, it doesn't response with None, but with a "none" string? if so, please change the return type documented here from Optional[str] to str

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets write it a bit clearer:

If the key exists, the type of the stored value is returned; otherwise, a "none" string is returned.


Returns:
Optional[str]: The type of value stored at `key`, or "none" when key doesn't exist.
The different types that can be returned are: string, list, set, zset, hash and stream.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this line as it would require us to maintain it with new types will be added to redis, and, also - when modules are being loaded we might have more types

The different types that can be returned are: string, list, set, zset, hash and stream.

Examples:
>>> await client.type("my_key")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets expand the example a bit-

>>> await client.set("key", "value")
>>> await client.type("key")
'string'

key (str): The key to check its data type.

Commands response:
Optional[str]: The type of value stored at `key`, or "none" when key doesn't exist.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@barshaul barshaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix & merge

@shohamazon shohamazon merged commit 0a233c1 into valkey-io:main Feb 13, 2024
27 checks passed
@shohamazon shohamazon deleted the python/type branch February 13, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants