From d08cbd1644686fe468b3fc849a4831ed1b7e53e6 Mon Sep 17 00:00:00 2001 From: SophiaPerzan-DG Date: Mon, 14 Sep 2026 11:52:42 -0400 Subject: [PATCH] fix: raise when non-bool passed to DisjointIntervalSequence.dna() --- genome_kit/diseq.py | 4 ++++ tests/test_diseq.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/genome_kit/diseq.py b/genome_kit/diseq.py index 28366658..a8d8fbf3 100644 --- a/genome_kit/diseq.py +++ b/genome_kit/diseq.py @@ -1046,6 +1046,10 @@ def dna(self, allow_outside_coord: bool = True) -> str: If the segment extends past the coord intervals and ``allow_outside_coord`` is False. """ + if type(allow_outside_coord) is not bool: + raise TypeError( + f"allow_outside_coord must be a bool, got {type(allow_outside_coord).__name__}" + ) if self._start == self._end: return "" diff --git a/tests/test_diseq.py b/tests/test_diseq.py index 9c1e76d9..f7a9e764 100644 --- a/tests/test_diseq.py +++ b/tests/test_diseq.py @@ -2663,6 +2663,13 @@ def test_off_coord_strand_minus_coord_multi_interval(self): ) self.assertEqual(dis.dna(), expected) + def test_passing_non_bool_raises(self): + ivs = _make_intervals([("chr1", "+", 100, 200)]) + dis = DisjointIntervalSequence(ivs, on_coordinate_strand=False, start=0, end=50) + dis2 = dis.cut(10, 20) + with self.assertRaises(TypeError): + dis.dna(dis2) + if __name__ == "__main__": unittest.main()