Code-health observations in hm/phonemes.py, noted during the repo-polish pass
and deliberately left unchanged there (that pass was config/metadata only).
-
Duplicated constants. rooturl / url_term_and_phones / url_phones /
url_symbols are defined twice: once at module level and again verbatim as
Phone class attributes. Two sources of truth for the same four URLs.
-
Imports in the middle of the file. functools, operator, itertools
and collections are imported after the first three function definitions,
even though _text_to_term_and_phones (defined above them) uses
methodcaller. It works only because the name is resolved at call time.
Confusing to read and fragile if anything ever runs at import time.
-
term_and_phones() looks vestigial. The module-level term_and_phones()
function is not exported from hm/__init__.py and duplicates what
Phone.tp does. Either promote it (export + docstring + doctest) or drop it.
-
Phone.__init__ shadowing. self.url_term_and_phones = url_term_and_phones or self.url_term_and_phones reads the class attribute to default the instance
attribute. It works, but a keyword-only argument with an explicit default
would be clearer.
None of these are bugs today. Filing so the cleanup is pickup-able rather than
lost. Related: #1 (making the data fetch cacheable would touch the same code).
Code-health observations in
hm/phonemes.py, noted during the repo-polish passand deliberately left unchanged there (that pass was config/metadata only).
Duplicated constants.
rooturl/url_term_and_phones/url_phones/url_symbolsare defined twice: once at module level and again verbatim asPhoneclass attributes. Two sources of truth for the same four URLs.Imports in the middle of the file.
functools,operator,itertoolsand
collectionsare imported after the first three function definitions,even though
_text_to_term_and_phones(defined above them) usesmethodcaller. It works only because the name is resolved at call time.Confusing to read and fragile if anything ever runs at import time.
term_and_phones()looks vestigial. The module-levelterm_and_phones()function is not exported from
hm/__init__.pyand duplicates whatPhone.tpdoes. Either promote it (export + docstring + doctest) or drop it.Phone.__init__shadowing.self.url_term_and_phones = url_term_and_phones or self.url_term_and_phonesreads the class attribute to default the instanceattribute. It works, but a keyword-only argument with an explicit default
would be clearer.
None of these are bugs today. Filing so the cleanup is pickup-able rather than
lost. Related: #1 (making the data fetch cacheable would touch the same code).