Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c36f5d

Browse files
committed
avoided unnecessary type casting
1 parentd535741 commit0c36f5d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

‎string_utils/generation.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
fromuuidimportuuid4
1717

1818
from .manipulationimportroman_encode
19-
from .validationimportis_integer
2019

2120

2221
defuuid(as_hex:bool=False)->str:
@@ -51,7 +50,7 @@ def random_string(size: int) -> str:
5150
:type size: int
5251
:return: Random string
5352
"""
54-
ifnotis_integer(str(size))orsize<1:
53+
ifnotisinstance(size,int)orsize<1:
5554
raiseValueError('size must be >= 1')
5655

5756
chars=string.ascii_letters+string.digits
@@ -76,7 +75,7 @@ def secure_random_hex(byte_count: int) -> str:
7675
:type byte_count: int
7776
:return: Hexadecimal string representation of generated random bytes
7877
"""
79-
ifnotis_integer(str(byte_count))orbyte_count<1:
78+
ifnotisinstance(byte_count,int)orbyte_count<1:
8079
raiseValueError('byte_count must be >= 1')
8180

8281
random_bytes=os.urandom(byte_count)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp