m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
423 B

6 months ago
  1. from typing import Optional
  2. def pick_bool(*values: Optional[bool]) -> bool:
  3. """Pick the first non-none bool or return the last value.
  4. Args:
  5. *values (bool): Any number of boolean or None values.
  6. Returns:
  7. bool: First non-none boolean.
  8. """
  9. assert values, "1 or more values required"
  10. for value in values:
  11. if value is not None:
  12. return value
  13. return bool(value)