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

Add none=False default to strict mode, or different option #231

Open
lod opened this issue Oct 31, 2023 · 0 comments
Open

Add none=False default to strict mode, or different option #231

lod opened this issue Oct 31, 2023 · 0 comments

Comments

@lod
Copy link

lod commented Oct 31, 2023

The practice of accepting None as a valid value for optional keys is surprising and hard to debug. I don't feel it should be accepted in a schema managed file, particularly if the strict mode is specified. Possibly a --strict-types option (and equivalent function parameter) should be used to preserve backwards compatibility.

For example including a map doesn't require the presence of elements of that map

Include schema with optional portion:

base:
  element: include('element', required=False)
---
element:
  required_field: str()

Pass because element is None, despite missing required_field

base:
  element:

Adding the none=False field here produces the expected behaviour, it should be the default behaviour.

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

No branches or pull requests

1 participant