Skip to content

Commit 6ef3f89

Browse files
authored
Replace the old strtobool function (#65)
1 parent 7a1d8e7 commit 6ef3f89

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

dataclass_csv/dataclass_reader.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import csv
33

44
from datetime import date, datetime
5-
from distutils.util import strtobool
6-
from typing import Union, Type, Optional, Sequence, Dict, Any, List
5+
from typing import Union, Type, Optional, Sequence, Dict, Any
76

87
import typing
98

@@ -12,6 +11,16 @@
1211

1312
from collections import Counter
1413

14+
def strtobool(value: str) -> bool:
15+
trueValues = ["true", "yes", "t", "y", "on", "1"]
16+
17+
validValues = ["false", "no", "f", "n", "off", "0", *trueValues]
18+
19+
if value.lower() not in validValues:
20+
raise ValueError(f"invalid boolean value {value}")
21+
22+
return value.lower() in trueValues
23+
1524

1625
def _verify_duplicate_header_items(header):
1726
if header is not None and len(header) == 0:

0 commit comments

Comments
 (0)