mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
fix(mypy): type annotations for conversions algorithms (#4314)
* fix(mypy): type annotations for conversions algorithms * refactor(CI): include conversions algorithms for mypy tests
This commit is contained in:
@ -28,9 +28,9 @@ def decimal_to_binary(num: int) -> str:
|
||||
TypeError: 'str' object cannot be interpreted as an integer
|
||||
"""
|
||||
|
||||
if type(num) == float:
|
||||
if isinstance(num, float):
|
||||
raise TypeError("'float' object cannot be interpreted as an integer")
|
||||
if type(num) == str:
|
||||
if isinstance(num, str):
|
||||
raise TypeError("'str' object cannot be interpreted as an integer")
|
||||
|
||||
if num == 0:
|
||||
@ -42,7 +42,7 @@ def decimal_to_binary(num: int) -> str:
|
||||
negative = True
|
||||
num = -num
|
||||
|
||||
binary = []
|
||||
binary: list[int] = []
|
||||
while num > 0:
|
||||
binary.insert(0, num % 2)
|
||||
num >>= 1
|
||||
|
Reference in New Issue
Block a user