From 52d39550673b98e6201fd588238cc572daf50070 Mon Sep 17 00:00:00 2001 From: Oren Halvani Date: Fri, 21 Aug 2026 13:39:17 +0000 Subject: [PATCH] fix(core): replace incorrect NoReturn with None type hints Three methods annotated -> NoReturn actually return normally: __jsonfiles_present (returns None when files present, only raises on missing files), __init__ (constructors must return None), and pretty_print (prints and returns None). NoReturn means "never returns normally", which caused IDEs/type checkers to flag all code after these calls as unreachable (see issue #2). Fixes #2 --- alphabetic/core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/alphabetic/core.py b/alphabetic/core.py index 68171f3..916f404 100644 --- a/alphabetic/core.py +++ b/alphabetic/core.py @@ -5,7 +5,7 @@ from jamo import h2j, j2hcj from pathlib import Path from enum import Enum, auto -from typing import Union, NoReturn +from typing import Union from .errors import Non_Existing_ISO_639_2_Langcode module_dir = os.path.dirname(os.path.abspath(__file__)) @@ -462,7 +462,7 @@ class Featural (Enum): Hangul = "Hang", - def __jsonfiles_present(self) -> NoReturn: + def __jsonfiles_present(self) -> None: """ Checks the presence of required JSON files and raises an error if any are missing. @@ -522,7 +522,7 @@ def __mapping_writing_systems_to_scripts(self) -> dict: return {ws_name:set(list("".join(["".join(d['script']) for d in script]))) for ws_name, script in writing_systen_map_script.items()} - def __init__(self) -> NoReturn: + def __init__(self) -> None: self.__jsonfiles_present() self.writing_systems_to_scripts = self.__mapping_writing_systems_to_scripts() self.iso_15924_to_iso_639_2_3 = { "Hang" : set(["kor", "jje"]), } # Required for fallback strategy (ISO 639-2/3 language code --> ISO 15924) @@ -662,7 +662,7 @@ def is_featural(self, sequence: str, strip_spaces: bool = True) -> bool: return self.is_writing_system(sequence, self.Featural.__name__, strip_spaces) - def pretty_print(self, script_dict: dict, show_script_key: bool = False) -> NoReturn: + def pretty_print(self, script_dict: dict, show_script_key: bool = False) -> None: """ Pretty print the contents of a dictionary where keys are script names and values are lists of characters. @@ -675,7 +675,7 @@ def pretty_print(self, script_dict: dict, show_script_key: bool = False) -> NoRe show_script_key (bool): Whether to print the script name (key) before the characters. Default is False. Returns: - NoReturn: This function does not return anything. It prints the output directly. + None: This function does not return anything. It prints the output directly. Example: >>> script_dict = {