alecthomas / voluptuous

CONTRIBUTIONS ONLY: Voluptuous, despite the name, is a Python data validation library.
https://pypi.org/project/voluptuous
BSD 3-Clause "New" or "Revised" License
1.82k stars 218 forks source link

Remove Maybe validator typing #517

Closed cdce8p closed 4 months ago

cdce8p commented 4 months ago

Ref https://github.com/home-assistant/core/pull/120450#issuecomment-2189661020

The validator type for Maybe shouldn't be limited to Callable. In the end it is passed to _WithSubValidators through validators which is currently untyped. https://github.com/alecthomas/voluptuous/blob/2232c0e556bc68343388fa8499bdbf13196a7514/voluptuous/validators.py#L218-L228

Removed the incorrect typing from Maybe for now.

Refs https://github.com/home-assistant/core/pull/120268

alecthomas commented 4 months ago

I don't really understand this change. All validators are callable, so this seems like it should be a valid constraint.

alecthomas commented 4 months ago

But maybe it should be using Schemable instead

cdce8p commented 4 months ago

All validators are callable, so this seems like it should be a valid constraint.

Validators can be callables but don't have to. Just as example, consider vol.Maybe({"key": int}).

Schemable seems to be a good alternative. Used that instead.

alecthomas commented 4 months ago

Sweet, thanks.