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

Remove value enumeration when validating empty list #434

Merged
merged 2 commits into from
Dec 6, 2020

Conversation

monopolis
Copy link
Contributor

The behaviour seems to have been introduced in commit
95489bd that modified the schema of an empty list in order
to provide a consistent behaviour between Schema({}) and Schema([]).

The commit introduced an enumeration of the incorrect values rather
than the expected behaviour of showing the key with the incorrect
value.

This commit provides the expected behaviour, and is also consistent
with the 'pathless' behaviour currently implemented, meaning that

  • Schema([])([1]) -> 'not a valid value @ data[1]'
  • Schema({'key': []})({'key': [1]) -> 'not a valid dictionary value @ data['key'].

Finally, as new unit test is provided to ensure that the new behaviour
remains intact.

.. so that you can e.g. run `tox -- --pdb` to get a debugger
on test failures.
The behaviour seems to have been introduced in commit
95489bd that modified the schema of an empty list in order
to provide a consistent behaviour between Schema({}) and Schema([]).

The commit introduced an enumeration of the incorrect values rather
than the expected behaviour of showing the key with the incorrect
value.

This commit provides the expected behaviour, and is also consistent
with the 'pathless' behaviour currently implemented, meaning that

- Schema([])([1]) -> 'not a valid value @ data[1]'
- Schema({'key': []})({'key': [1]) -> 'not a valid dictionary value @
data['key'].

Finally, as new unit test is provided to ensure that the new behaviour
remains intact.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 95.617% when pulling 10a78d0 on monopolis:issue-397 into 7151438 on alecthomas:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 95.617% when pulling 10a78d0 on monopolis:issue-397 into 7151438 on alecthomas:master.

@spacegaier spacegaier changed the title Remove value enumeration when validating empty list (#397) Remove value enumeration when validating empty list Dec 6, 2020
@spacegaier spacegaier linked an issue Dec 6, 2020 that may be closed by this pull request
@spacegaier spacegaier merged commit 1a7cb81 into alecthomas:master Dec 6, 2020
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.

Empty lists behaving incorrectly
3 participants