Skip to content

Commit b345bf1

Browse files
committed
chore: use typing.cast instead of type assertion
1 parent 18809d5 commit b345bf1

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

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 binary 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)