Remove some unnecessary uses of regular expressions (#101182)

This commit is contained in:
Ville Skyttä 2023-10-04 04:55:00 +03:00 committed by GitHub
parent 09ba34fb3a
commit 5551a345ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 16 deletions

View file

@ -203,12 +203,9 @@ def boolean(value: Any) -> bool:
raise vol.Invalid(f"invalid boolean value {value}")
_WS = re.compile("\\s*")
def whitespace(value: Any) -> str:
"""Validate result contains only whitespace."""
if isinstance(value, str) and _WS.fullmatch(value):
if isinstance(value, str) and (value == "" or value.isspace()):
return value
raise vol.Invalid(f"contains non-whitespace: {value}")