[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-10-01 08:03:15 +00:00
parent 02ff53c1e8
commit a696268791

View File

@ -1,13 +1,13 @@
def is_upper(string: str) -> bool: def is_upper(string: str) -> bool:
""" """
Check if all characters in the string are uppercase letters. Check if all characters in the string are uppercase letters.
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if all characters in the string are uppercase letters, False otherwise. bool: True if all characters in the string are uppercase letters, False otherwise.
Examples: Examples:
>>> is_upper("HELLO") >>> is_upper("HELLO")
True True
@ -16,16 +16,17 @@ def is_upper(string: str) -> bool:
""" """
return all(ord(char) >= 65 and ord(char) <= 90 for char in string) return all(ord(char) >= 65 and ord(char) <= 90 for char in string)
def is_lower(string: str) -> bool: def is_lower(string: str) -> bool:
""" """
Check if all characters in the string are lowercase letters. Check if all characters in the string are lowercase letters.
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if all characters in the string are lowercase letters, False otherwise. bool: True if all characters in the string are lowercase letters, False otherwise.
Examples: Examples:
>>> is_lower("hello") >>> is_lower("hello")
True True
@ -34,16 +35,17 @@ def is_lower(string: str) -> bool:
""" """
return all(ord(char) >= 97 and ord(char) <= 122 for char in string) return all(ord(char) >= 97 and ord(char) <= 122 for char in string)
def is_alpha(string: str) -> bool: def is_alpha(string: str) -> bool:
""" """
Check if all characters in the string are alphabetical (letters). Check if all characters in the string are alphabetical (letters).
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if all characters in the string are letters, False otherwise. bool: True if all characters in the string are letters, False otherwise.
Examples: Examples:
>>> is_alpha("Hello") >>> is_alpha("Hello")
True True
@ -52,16 +54,17 @@ def is_alpha(string: str) -> bool:
""" """
return all(char.isalpha() for char in string) return all(char.isalpha() for char in string)
def is_alnum(string: str) -> bool: def is_alnum(string: str) -> bool:
""" """
Check if all characters in the string are alphanumeric (letters or digits). Check if all characters in the string are alphanumeric (letters or digits).
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if all characters in the string are letters or digits, False otherwise. bool: True if all characters in the string are letters or digits, False otherwise.
Examples: Examples:
>>> is_alnum("Hello123") >>> is_alnum("Hello123")
True True
@ -70,16 +73,17 @@ def is_alnum(string: str) -> bool:
""" """
return all(char.isalnum() for char in string) return all(char.isalnum() for char in string)
def is_decimal(string: str) -> bool: def is_decimal(string: str) -> bool:
""" """
Check if all characters in the string are decimal digits. Check if all characters in the string are decimal digits.
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if all characters in the string are decimal digits, False otherwise. bool: True if all characters in the string are decimal digits, False otherwise.
Examples: Examples:
>>> is_decimal("12345") >>> is_decimal("12345")
True True
@ -88,16 +92,17 @@ def is_decimal(string: str) -> bool:
""" """
return all(char.isdigit() for char in string) return all(char.isdigit() for char in string)
def is_space(string: str) -> bool: def is_space(string: str) -> bool:
""" """
Check if all characters in the string are whitespace characters. Check if all characters in the string are whitespace characters.
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if all characters in the string are whitespace characters, False otherwise. bool: True if all characters in the string are whitespace characters, False otherwise.
Examples: Examples:
>>> is_space(" \\t\\n") >>> is_space(" \\t\\n")
True True
@ -106,16 +111,17 @@ def is_space(string: str) -> bool:
""" """
return all(char.isspace() for char in string) return all(char.isspace() for char in string)
def is_title(string: str) -> bool: def is_title(string: str) -> bool:
""" """
Check if the string is in title case (first letter of each word is capital). Check if the string is in title case (first letter of each word is capital).
Args: Args:
string (str): The input string. string (str): The input string.
Returns: Returns:
bool: True if the string is in title case, False otherwise. bool: True if the string is in title case, False otherwise.
Examples: Examples:
>>> is_title("This Is A Title Case String") >>> is_title("This Is A Title Case String")
True True
@ -124,6 +130,8 @@ def is_title(string: str) -> bool:
""" """
return string.istitle() return string.istitle()
if __name__ == "__main__": if __name__ == "__main__":
import doctest import doctest
doctest.testmod()
doctest.testmod()