Skip to content

Commit 375d8c2

Browse files
pgimalacofek
authored andcommitted
chore: use typing.cast instead of type assertion
1 parent 1b42b88 commit 375d8c2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

binary/core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from decimal import Decimal
22
from typing import TYPE_CHECKING, NamedTuple, Optional, Tuple, Union
3+
import typing
34

45
BYTE = 1
56

@@ -169,9 +170,7 @@ def convert_units(
169170
except KeyError:
170171
raise ValueError(f'{to} is not a valid unit.')
171172

172-
babs = abs(b)
173-
if TYPE_CHECKING:
174-
assert isinstance(babs, float) or isinstance(babs, Decimal)
173+
babs = typing.cast(Union[float, Decimal], abs(b))
175174

176175
if unit in BINARY_PREFIXES and not si:
177176
if babs < KIBIBYTE:

0 commit comments

Comments
 (0)