diff --git a/melusine/base.py b/melusine/base.py index 751266a..1f299e2 100644 --- a/melusine/base.py +++ b/melusine/base.py @@ -530,7 +530,7 @@ def describe(self, text: str, position: bool = False) -> None: position: If True, print regex match start and stop positions. """ - def _describe_match_field(match_field_data: Dict[str, List[Dict[str, Any]]]) -> None: + def _describe_match_field(match_field_data: dict[str, list[dict[str, Any]]]) -> None: """ Format and print result description text. @@ -609,7 +609,7 @@ def pre_match_hook(self, text: str) -> str: """ return text - def post_match_hook(self, match_dict: Dict[str, Any]) -> Dict[str, Any]: + def post_match_hook(self, match_dict: dict[str, Any]) -> dict[str, Any]: """ Hook to run after the Melusine regex match. diff --git a/tests/base/test_melusine_regex.py b/tests/base/test_melusine_regex.py index 03918b8..721412d 100644 --- a/tests/base/test_melusine_regex.py +++ b/tests/base/test_melusine_regex.py @@ -153,7 +153,6 @@ def no_match_list(self): class PreMatchHookVirusRegex(VirusRegex): - def pre_match_hook(self, text: str) -> str: text = text.replace("virrrrus", "virus") return text @@ -168,12 +167,14 @@ def test_pre_match_hook(): class PostMatchHookVirusRegex(VirusRegex): - def post_match_hook(self, match_dict: Dict[str, Any]) -> Dict[str, Any]: """Test custom post processing of match data""" - if match_dict[self.MATCH_RESULT] is True: - if "NEUTRAL_MEDICAL_VIRUS" in match_dict[self.NEUTRAL_MATCH_FIELD] and "NEUTRAL_INSECT" in match_dict[self.NEUTRAL_MATCH_FIELD]: - match_dict[self.MATCH_RESULT] = False + if ( + match_dict[self.MATCH_RESULT] is True + and "NEUTRAL_MEDICAL_VIRUS" in match_dict[self.NEUTRAL_MATCH_FIELD] + and "NEUTRAL_INSECT" in match_dict[self.NEUTRAL_MATCH_FIELD] + ): + match_dict[self.MATCH_RESULT] = False return match_dict