Skip to content

Commit f0ac220

Browse files
committed
Remove catch/throw of an already thrown exception. self._is_valid_gl throws InvalidAlleleError
1 parent a6c98ae commit f0ac220

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

pyard/ard.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,7 @@ def validate(self, glstring):
440440
:param glstring: GL String to validate
441441
:return: boolean indicating success
442442
"""
443-
try:
444-
return self._is_valid_gl(glstring)
445-
except InvalidAlleleError as e:
446-
raise InvalidTypingError(
447-
f"{glstring} is not valid GL String. \n {e.message}", e
448-
) from None
443+
return self._is_valid_gl(glstring)
449444

450445
def is_XX(self, glstring: str, loc_antigen: str = None, code: str = None) -> bool:
451446
if loc_antigen is None or code is None:

tests/steps/mac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from behave import *
22
from hamcrest import assert_that, is_
33

4-
from pyard.exceptions import InvalidTypingError
4+
from pyard.exceptions import InvalidAlleleError
55

66

77
@given("the MAC code is {mac_code}")
@@ -38,7 +38,7 @@ def step_impl(context, mac_code):
3838
def step_impl(context):
3939
try:
4040
context.is_valid = context.ard.validate(context.mac_code)
41-
except InvalidTypingError:
41+
except InvalidAlleleError:
4242
context.is_valid = False
4343

4444

tests/test_pyard.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import pyard
3636
from pyard.constants import DEFAULT_CACHE_SIZE
37-
from pyard.exceptions import InvalidAlleleError, InvalidMACError, InvalidTypingError
37+
from pyard.exceptions import InvalidAlleleError
3838
from pyard.misc import validate_reduction_type
3939

4040

@@ -135,15 +135,15 @@ def test_redux_types(self):
135135
validate_reduction_type("XX")
136136

137137
def test_empty_allele(self):
138-
with self.assertRaises(InvalidTypingError):
138+
with self.assertRaises(InvalidAlleleError):
139139
self.ard.redux("A*", "lgx")
140140

141141
def test_fp_allele(self):
142-
with self.assertRaises(InvalidTypingError):
142+
with self.assertRaises(InvalidAlleleError):
143143
self.ard.redux("A*0.123", "lgx")
144144

145145
def test_empty_fields(self):
146-
with self.assertRaises(InvalidTypingError):
146+
with self.assertRaises(InvalidAlleleError):
147147
# : without any data
148148
self.ard.redux("DQA1*01:01:01:G", "lgx")
149149

@@ -152,7 +152,7 @@ def test_invalid_serology(self):
152152
serology_a10 = self.ard.redux("A10", "lgx")
153153
self.assertEqual(serology_a10.split("/")[0], "A*25:01")
154154
# And A100 isn't a valid typing
155-
with self.assertRaises(InvalidTypingError):
155+
with self.assertRaises(InvalidAlleleError):
156156
self.ard.redux("A100", "lgx")
157157

158158
def test_allele_duplicated(self):

0 commit comments

Comments
 (0)