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

Fix typing of HashCommand.hdel #3029

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4927,7 +4927,7 @@ class HashCommands(CommandsProtocol):
see: https://redis.io/topics/data-types-intro#redis-hashes
"""

def hdel(self, name: str, *keys: List) -> Union[Awaitable[int], int]:
def hdel(self, name: str, *keys: str) -> Union[Awaitable[int], int]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this should be List[str] (source)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it's not. Select something from:

  • hdel(self, name: str, keys: List[str]) - strange way... but if you really want List - you can go with it.
  • hdel(self, name: str, *keys: str) - preferred, pythonic way to type arbitrary argument list

python-unpacking and List typing cannot be used same time, because right now *keys: List[str] -- means that in function it will be keys: tuple[List[str], ...] (you are missing that *args should be typed in a different way than ordinary function argument).

https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values

"""
Delete ``keys`` from hash ``name``

Expand Down