Skip to content

Commit 54af2f9

Browse files
committed
Replace 'int | float' with 'float'
1 parent c86b138 commit 54af2f9

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/humanize/filesize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def naturalsize(
14-
value: int | float | str,
14+
value: float | str,
1515
binary: bool = False,
1616
gnu: bool = False,
1717
format: str = "%.1f",

src/humanize/number.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# This type can be better defined by typing.SupportsInt, typing.SupportsFloat
2525
# but that's a Python 3.8 only typing option.
26-
NumberOrString: TypeAlias = "int | float | str"
26+
NumberOrString: TypeAlias = "float | str"
2727

2828

2929
def ordinal(value: NumberOrString, gender: str = "male") -> str:
@@ -407,10 +407,10 @@ def scientific(value: NumberOrString, precision: int = 2) -> str:
407407

408408

409409
def clamp(
410-
value: int | float,
410+
value: float,
411411
format: str = "{:}",
412-
floor: int | float | None = None,
413-
ceil: int | float | None = None,
412+
floor: float | None = None,
413+
ceil: float | None = None,
414414
floor_token: str = "<",
415415
ceil_token: str = ">",
416416
) -> str:

src/humanize/time.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ def naturaldate(value: dt.date | dt.datetime) -> str:
292292

293293

294294
def _quotient_and_remainder(
295-
value: int | float,
296-
divisor: int | float,
295+
value: float,
296+
divisor: float,
297297
unit: Unit,
298298
minimum_unit: Unit,
299299
suppress: collections.abc.Iterable[Unit],
@@ -331,9 +331,9 @@ def _quotient_and_remainder(
331331

332332

333333
def _carry(
334-
value1: int | float,
335-
value2: int | float,
336-
ratio: int | float,
334+
value1: float,
335+
value2: float,
336+
ratio: float,
337337
unit: Unit,
338338
min_unit: Unit,
339339
suppress: typing.Iterable[Unit],

tests/test_number.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_apnumber(test_input: int | str, expected: str) -> None:
136136
(0.333, "333/1000"),
137137
],
138138
)
139-
def test_fractional(test_input: int | float | str, expected: str) -> None:
139+
def test_fractional(test_input: float | str, expected: str) -> None:
140140
assert humanize.fractional(test_input) == expected
141141

142142

tests/test_time.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_naturaldate(test_input: dt.date, expected: str) -> None:
286286
(ONE_YEAR + FOUR_MICROSECONDS, "a year"),
287287
],
288288
)
289-
def test_naturaldelta_minimum_unit_default(seconds: int | float, expected: str) -> None:
289+
def test_naturaldelta_minimum_unit_default(seconds: float, expected: str) -> None:
290290
# Arrange
291291
delta = dt.timedelta(seconds=seconds)
292292

@@ -330,7 +330,7 @@ def test_naturaldelta_minimum_unit_default(seconds: int | float, expected: str)
330330
],
331331
)
332332
def test_naturaldelta_minimum_unit_explicit(
333-
minimum_unit: str, seconds: int | float, expected: str
333+
minimum_unit: str, seconds: float, expected: str
334334
) -> None:
335335
# Arrange
336336
delta = dt.timedelta(seconds=seconds)
@@ -354,7 +354,7 @@ def test_naturaldelta_minimum_unit_explicit(
354354
(ONE_YEAR + FOUR_MICROSECONDS, "a year ago"),
355355
],
356356
)
357-
def test_naturaltime_minimum_unit_default(seconds: int | float, expected: str) -> None:
357+
def test_naturaltime_minimum_unit_default(seconds: float, expected: str) -> None:
358358
# Arrange
359359
datetime = NOW - dt.timedelta(seconds=seconds)
360360

@@ -399,7 +399,7 @@ def test_naturaltime_minimum_unit_default(seconds: int | float, expected: str) -
399399
],
400400
)
401401
def test_naturaltime_minimum_unit_explicit(
402-
minimum_unit: str, seconds: int | float, expected: str
402+
minimum_unit: str, seconds: float, expected: str
403403
) -> None:
404404
# Arrange
405405
datetime = NOW - dt.timedelta(seconds=seconds)

0 commit comments

Comments
 (0)