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

Display valid Enum values in Coerce #450

Closed epenet closed 2 years ago

epenet commented 2 years ago

Sample message: "expected EntityCategory or one of ['config', 'diagnostic', 'system']"

epenet commented 2 years ago

Sorry to chase, but is it likely to be considered? Or should it be handled inside Home Assistant?

alecthomas commented 2 years ago

Seems reasonable. Do the tests pass? I haven't set up CI since Travis died.

epenet commented 2 years ago

They do on my machine:

nosetests
.......................................................................................................................................................................................
----------------------------------------------------------------------
Ran 183 tests in 0.088s

OK
epenet commented 2 years ago

Added tests:

nosetests --with-coverage --cover-package=voluptuous
........................................................................................................................................................................................
Name                           Stmts   Miss  Cover
--------------------------------------------------
voluptuous/__init__.py             6      0   100%
voluptuous/error.py               78      2    97%
voluptuous/humanize.py            22      7    68%
voluptuous/schema_builder.py     509     18    96%
voluptuous/util.py                63      7    89%
voluptuous/validators.py         460     13    97%
--------------------------------------------------
TOTAL                           1138     47    96%
----------------------------------------------------------------------
Ran 184 tests in 0.139s

OK
alecthomas commented 2 years ago

Would you mind formatting this without the list brackets? eg. one of 1, 2, 3 or one of 'one', 'two', 'three'`

epenet commented 2 years ago

Adjusted without the brackets, and added tests for a string enum.

nosetests --with-coverage --cover-package=voluptuous
........................................................................................................................................................................................
Name                           Stmts   Miss  Cover
--------------------------------------------------
voluptuous/__init__.py             6      0   100%
voluptuous/error.py               78      2    97%
voluptuous/humanize.py            22      7    68%
voluptuous/schema_builder.py     509     18    96%
voluptuous/util.py                63      7    89%
voluptuous/validators.py         460     13    97%
--------------------------------------------------
TOTAL                           1138     47    96%
----------------------------------------------------------------------
Ran 184 tests in 0.132s

OK
alecthomas commented 2 years ago

Perfect, thank you so much!

epenet commented 2 years ago

Thanks 👍

epenet commented 2 years ago

Let me know when the release is available...

epenet commented 2 years ago

Any luck with the release ?

jamesbraid commented 2 years ago

This broke for py2.7, homepage still lists py2.7 as being supported... what to do?