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()