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

Improve typing for function uuid7 #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mahmoudajawad
Copy link

This change adds overload variants for uuid7 function to vet the return type based on value of argument as_type.

Unfortunately, this was made possible only by making arguments as_type, time_func, _last, and _last_as_of keyword-only. However, I assume this should be fine as:

  • This lib has not been published as stable v1 API.
  • The provided example in function documentation uses keyword when referred to as_type.
  • Other arguments are barely to be used in most of the cases for generating UUIDs.

With this change:

uuid7() # revealed type is: UUID
uuid7(as_type=None) # revealed type is: UUID
uuid7(as_type="str") # revealed type is: str
uuid7(as_type="int") # revealed type is: int
uuid7(as_type="bytes") # revealed type is: bytes

This change takes in mind that current function documentation referred to use of argument ns as positional argument, and as such, argument ns was exempted from being also keyword-only.

Looking forward to hearing any feedback on this, or seeing it merged if the breaking changes are within the acceptable range.

- Add overload variants for `uuid7` function to vet the return type based on value of argument `as_type`
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

Successfully merging this pull request may close these issues.

1 participant