more docs

This commit is contained in:
Jesse Bannon 2023-11-18 23:05:42 -08:00
parent 552bc6c05e
commit 8c6c4ebc75
2 changed files with 40 additions and 3 deletions

View file

@ -3,48 +3,84 @@ from ytdl_sub.script.types.resolvable import Boolean
class BooleanFunctions:
"""
Comparison functions that output Booleans.
"""
@staticmethod
def bool(value: AnyType) -> Boolean:
"""
Cast any type to a boolean
Cast any type to a Boolean.
"""
return Boolean(bool(value.value))
@staticmethod
def equals(left: AnyType, right: AnyType) -> Boolean:
def eq(left: AnyType, right: AnyType) -> Boolean:
"""
Returns True if left equals right. False otherwise.
``==`` operator. Returns True if left == right. False otherwise.
"""
return Boolean(left.value == right.value)
@staticmethod
def ne(left: AnyType, right: AnyType) -> Boolean:
"""
``!=`` operator. Returns True if left != right. False otherwise.
"""
return Boolean(left.value != right.value)
@staticmethod
def lt(left: AnyType, right: AnyType) -> Boolean:
"""
``<`` operator. Returns True if left < right. False otherwise.
"""
return Boolean(left.value < right.value)
@staticmethod
def lte(left: AnyType, right: AnyType) -> Boolean:
"""
``<=`` operator. Returns True if left <= right. False otherwise.
"""
return Boolean(left.value <= right.value)
@staticmethod
def gt(left: AnyType, right: AnyType) -> Boolean:
"""
``>`` operator. Returns True if left > right. False otherwise.
"""
return Boolean(left.value > right.value)
@staticmethod
def gte(left: AnyType, right: AnyType) -> Boolean:
"""
``>=`` operator. Returns True if left >= right. False otherwise.
"""
return Boolean(left.value >= right.value)
@staticmethod
def and_(left: Boolean, right: Boolean) -> Boolean:
"""
``and`` operator. Returns True if left and right are both True. False otherwise.
"""
return Boolean(left.value and right.value)
@staticmethod
def or_(left: Boolean, right: Boolean) -> Boolean:
"""
``or`` operator. Returns True if either left or right are True. False otherwise.
"""
return Boolean(left.value or right.value)
@staticmethod
def xor(left: Boolean, right: Boolean) -> Boolean:
"""
``^`` operator. Returns True if either left or right are True and the other is False.
Returns False otherwise.
"""
return Boolean(left.value ^ right.value)
@staticmethod
def not_(value: Boolean) -> Boolean:
"""
``not`` operator. Returns the opposite of value.
"""
return Boolean(not value.value)

View file

@ -14,6 +14,7 @@ from ytdl_sub.script.utils.exceptions import UNREACHABLE
# pylint: disable=missing-raises-doc
def is_union(arg_type: Type) -> bool:
"""
Returns