From 8c6c4ebc757d6ef5036b412f56bbe630afcc19d6 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 18 Nov 2023 23:05:42 -0800 Subject: [PATCH] more docs --- .../script/functions/boolean_functions.py | 42 +++++++++++++++++-- src/ytdl_sub/script/utils/type_checking.py | 1 + 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/ytdl_sub/script/functions/boolean_functions.py b/src/ytdl_sub/script/functions/boolean_functions.py index db038cf6..bd024b3d 100644 --- a/src/ytdl_sub/script/functions/boolean_functions.py +++ b/src/ytdl_sub/script/functions/boolean_functions.py @@ -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) diff --git a/src/ytdl_sub/script/utils/type_checking.py b/src/ytdl_sub/script/utils/type_checking.py index 6bbbdacd..452353dc 100644 --- a/src/ytdl_sub/script/utils/type_checking.py +++ b/src/ytdl_sub/script/utils/type_checking.py @@ -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