Skip to content

Commit 4edc75b

Browse files
authored
Merge pull request #145 from static-frame/143/pyi-improvements
Updates to .pyi file
2 parents a076a43 + f6cd149 commit 4edc75b

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def delimited_to_arrays(
7878
line_select: tp.Optional[tp.Callable[[int], bool]] = None,
7979
delimiter: str = ',',
8080
doublequote: bool = True,
81-
escapechar: str = '',
82-
quotechar: str = '"',
81+
escapechar: tp.Optional[str] = '',
82+
quotechar: tp.Optional[str] = '"',
8383
quoting: int = 0,
8484
skipinitialspace: bool = False,
8585
strict: bool = False,
@@ -93,8 +93,8 @@ def split_after_count(
9393
delimiter: str = ',',
9494
count: int = 0,
9595
doublequote: bool = True,
96-
escapechar: str = '',
97-
quotechar: str = '"',
96+
escapechar: tp.Optional[str] = '',
97+
quotechar: tp.Optional[str] = '"',
9898
quoting: int = 0,
9999
strict: bool = False,
100100
) -> tp.Tuple[str, str]: ...

src/_arraykit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ AK_set_int(const char *name,
319319
return 0;
320320
}
321321

322-
// Set a character from `src` on `target`; if src is NULL use default. Returns -1 on error, else 0.
322+
// Set a character from `src` on `target`; if src is NULL use default. Returns -1 on error, else 0. If a None is given, a null char will be assigned.
323323
static int
324324
AK_set_char(const char *name,
325325
Py_UCS4 *target,

test/test_delimited_to_arrays.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,12 @@ def test_delimited_to_arrays_delimiter_a(self) -> None:
871871
with self.assertRaises(TypeError):
872872
_ = delimited_to_arrays(msg, axis=1, delimiter='foo')
873873

874+
def test_delimited_to_arrays_delimiter_b(self) -> None:
875+
msg = ['a,3,True', 'b,-1,False']
876+
with self.assertRaises(TypeError):
877+
_ = delimited_to_arrays(msg, axis=1, delimiter=None)
878+
879+
874880
#---------------------------------------------------------------------------
875881
def test_delimited_to_arrays_escapechar_a(self) -> None:
876882
msg = ['a,3,True', 'b,-1,False']
@@ -889,6 +895,15 @@ def test_delimited_to_arrays_escapechar_b(self) -> None:
889895
self.assertEqual([a.tolist() for a in post1],
890896
[['f"oo', 'b,ar'], [3, -1], [True, False]])
891897

898+
def test_delimited_to_arrays_escapechar_c(self) -> None:
899+
msg = ['foo,3,True', 'bar,-1,False']
900+
post1 = delimited_to_arrays(msg,
901+
axis=1,
902+
escapechar=None,
903+
)
904+
self.assertEqual([a.tolist() for a in post1],
905+
[['foo', 'bar'], [3, -1], [True, False]])
906+
892907
#---------------------------------------------------------------------------
893908
def test_delimited_to_arrays_quotechar_a(self) -> None:
894909
msg = ['a,3,True', 'b,-1,False']
@@ -898,6 +913,12 @@ def test_delimited_to_arrays_quotechar_a(self) -> None:
898913
with self.assertRaises(TypeError):
899914
_ = delimited_to_arrays(msg, axis=1, quoting=csv.QUOTE_ALL, quotechar='foo')
900915

916+
with self.assertRaises(TypeError):
917+
_ = delimited_to_arrays(msg, axis=1, quoting=csv.QUOTE_ALL, quotechar=None)
918+
919+
_ = delimited_to_arrays(msg, axis=1, quoting=csv.QUOTE_NONE, quotechar=None)
920+
921+
901922
def test_delimited_to_arrays_quotechar_b(self) -> None:
902923
msg = ['|foo|,|3|,|True|', '|bar|,|-1|,|False|']
903924
post1 = delimited_to_arrays(msg, axis=1)

0 commit comments

Comments
 (0)