Skip to content

Commit

Permalink
avoided unnecessary type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
daveoncode committed Mar 4, 2020
1 parent d535741 commit 0c36f5d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions string_utils/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from uuid import uuid4

from .manipulation import roman_encode
from .validation import is_integer


def uuid(as_hex: bool = False) -> str:
Expand Down Expand Up @@ -51,7 +50,7 @@ def random_string(size: int) -> str:
:type size: int
:return: Random string
"""
if not is_integer(str(size)) or size < 1:
if not isinstance(size, int) or size < 1:
raise ValueError('size must be >= 1')

chars = string.ascii_letters + string.digits
Expand All @@ -76,7 +75,7 @@ def secure_random_hex(byte_count: int) -> str:
:type byte_count: int
:return: Hexadecimal string representation of generated random bytes
"""
if not is_integer(str(byte_count)) or byte_count < 1:
if not isinstance(byte_count, int) or byte_count < 1:
raise ValueError('byte_count must be >= 1')

random_bytes = os.urandom(byte_count)
Expand Down

0 comments on commit 0c36f5d

Please sign in to comment.