Closed antoni-szych-rtbhouse closed 9 months ago
Answering here for clarity:
Hi @ds-cbo, I've updated the typings to allow integers in paths in https://github.com/alecthomas/voluptuous/pull/497 (useful to show that the validation failed for e.g. 5th element of some list), but wanted to confirm with you - was there any special reason you decided to allow only strings in path?
There was no special reason other than "I imagine that this is the most logical" but I can see why integers could also be useful. While you're at it, I would suggest using typing.Hashable
directly, to prevent new PRs about the same issue. (As a bonus it's both shorter and clearer than typing.Union[str, int]]
)
While you're at it, I would suggest using
typing.Hashable
directly, to prevent new PRs about the same issue.
Sure thing, please take a look at the updated version.
Seems reasonable to me, can you add some tests for non-string keys please?
Seems reasonable to me, can you add some tests for non-string keys please?
Of course, I've added a few.
Thanks!
This is to address an issue introduced in https://github.com/alecthomas/voluptuous/pull/475
As I understand, in this PR, @ds-cbo assumed that the path fragments could only be strings. However, it just occured to me that there is no reason to not allow:
Just to confirm, I've checked the examples from the readme - it seems that they demonstrate exactly this - integers in path as list indices:
Also, this seems to be the intention behind the comment here: