Skip to content

Commit 05289bd

Browse files
Fix pre-commit errors
1 parent ba6e627 commit 05289bd

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/humanize/lists.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
"""Lists related humanization."""
12
from typing import AnyStr, List
23

34
__all__ = ["naturallist"]
45

56

67
def naturallist(items: List[AnyStr]) -> str:
7-
"""Convert a list of items into a human-readable string with commas and 'and'
8+
"""Natural list.
9+
10+
Convert a list of items into a human-readable string with commas and 'and'
811
912
Args:
1013
items (list): A list of strings
@@ -18,10 +21,9 @@ def naturallist(items: List[AnyStr]) -> str:
1821
>>> naturallist(["one"])
1922
'one'
2023
"""
21-
2224
if len(items) == 1:
23-
return items[0]
25+
return str(items[0])
2426
elif len(items) == 2:
25-
return f"{items[0]} and {items[1]}"
27+
return f"{str(items[0])} and {str(items[1])}"
2628
else:
27-
return ", ".join(items[:-1]) + f" and {items[-1]}"
29+
return ", ".join(str(item) for item in items[:-1]) + f" and {str(items[-1])}"

tests/test_lists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
([[""]], ""),
1414
],
1515
)
16-
def test_naturallist(test_args, expected):
16+
def test_naturallist(test_args: list[str], expected: str) -> None:
1717
assert humanize.naturallist(*test_args) == expected

0 commit comments

Comments
 (0)