Document ValueError being raised by UUID constructor#144425
Conversation
| @@ -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. | |||
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?
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...
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
There was a problem hiding this comment.
I am actually fine with documenting this. Sometimes we do document this, sometimes not.
|
This PR is stale because it has been open for 30 days with no activity. |
This is a trivial improvement that I think doesn't require an issue.
📚 Documentation preview 📚: https://cpython-previews--144425.org.readthedocs.build/