Document ValueError being raised by UUID constructor#144425
Open
Viicos wants to merge 1 commit intopython:mainfrom
Open
Document ValueError being raised by UUID constructor#144425Viicos wants to merge 1 commit intopython:mainfrom
ValueError being raised by UUID constructor#144425Viicos wants to merge 1 commit intopython:mainfrom
Conversation
Viicos
commented
Feb 3, 2026
| @@ -66,6 +66,7 @@ which relays any information about the UUID's safety, using this enumeration: | |||
| UUID(int=0x12345678123456781234567812345678) | |||
|
|
|||
| Exactly one of *hex*, *bytes*, *bytes_le*, *fields*, or *int* must be given. | |||
Contributor
Author
There was a problem hiding this comment.
We could also explicitly specify that this raises a TypeError, but I feel like this is generally known that invalid arguments raise TypeErrors?
Member
There was a problem hiding this comment.
Usually:
- Invalid signature/usage/object types -> TypeError
- Valid type but invalid data -> ValueError
The only exception I'm aware of is ipaddress which raises TypeErrors a bit everywhere...
Contributor
Author
There was a problem hiding this comment.
Hum then not documenting ValueError would maybe make sense? I had the correct assumption for TypeError, and wasn't sure for value errors but indeed it makes sense and once you know about this you can just write your try..except blocks from muscle memory
Member
There was a problem hiding this comment.
I am actually fine with documenting this. Sometimes we do document this, sometimes not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a trivial improvement that I think doesn't require an issue.
📚 Documentation preview 📚: https://cpython-previews--144425.org.readthedocs.build/