Skip to content

Commit 01a0a1f

Browse files
Copilotbact
andcommitted
Fix circular import issues caused by import sorting
Co-authored-by: bact <128572+bact@users.noreply.github.com>
1 parent 720b580 commit 01a0a1f

2 files changed

Lines changed: 30 additions & 30 deletions

File tree

pythainlp/corpus/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ def corpus_db_path() -> str:
9292
return _CORPUS_DB_PATH
9393

9494

95+
from pythainlp.corpus.core import (
96+
download,
97+
get_corpus,
98+
get_corpus_as_is,
99+
get_corpus_db,
100+
get_corpus_db_detail,
101+
get_corpus_default_db,
102+
get_corpus_path,
103+
get_hf_hub,
104+
get_path_folder_corpus,
105+
make_safe_directory_name,
106+
path_pythainlp_corpus,
107+
remove,
108+
) # these imports must come before other pythainlp.corpus.* imports
95109
from pythainlp.corpus.common import (
96110
countries,
97111
find_synonyms,
@@ -109,20 +123,6 @@ def corpus_db_path() -> str:
109123
thai_words,
110124
thai_wsd_dict,
111125
)
112-
from pythainlp.corpus.core import (
113-
download,
114-
get_corpus,
115-
get_corpus_as_is,
116-
get_corpus_db,
117-
get_corpus_db_detail,
118-
get_corpus_default_db,
119-
get_corpus_path,
120-
get_hf_hub,
121-
get_path_folder_corpus,
122-
make_safe_directory_name,
123-
path_pythainlp_corpus,
124-
remove,
125-
) # these imports must come before other pythainlp.corpus.* imports
126126
from pythainlp.corpus.icu import thai_icu_words
127127
from pythainlp.corpus.volubilis import thai_volubilis_words
128128
from pythainlp.corpus.wikipedia import thai_wikipedia_titles

pythainlp/util/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,10 @@
110110
)
111111
from pythainlp.util.numtoword import bahttext, num_to_thaiword
112112
from pythainlp.util.phoneme import ipa_to_rtgs, nectec_to_ipa, remove_tone_ipa
113-
from pythainlp.util.pronounce import (
114-
rhyme,
115-
spelling,
116-
thai_consonant_to_spelling,
117-
tone_to_spelling,
118-
)
119113
from pythainlp.util.remove_trailing_repeat_consonants import (
120114
remove_trailing_repeat_consonants,
121115
)
122116
from pythainlp.util.strftime import thai_strftime
123-
124-
# sound_syllable and pronounce have to be imported last,
125-
# to prevent circular import issues.
126-
# Other imports should be above this line, sorted.
127-
from pythainlp.util.syllable import (
128-
sound_syllable,
129-
syllable_length,
130-
syllable_open_close_detector,
131-
tone_detector,
132-
)
133117
from pythainlp.util.thai import (
134118
analyze_thai_text,
135119
count_thai_chars,
@@ -144,3 +128,19 @@
144128
from pythainlp.util.time import thaiword_to_time, time_to_thaiword
145129
from pythainlp.util.trie import Trie, dict_trie
146130
from pythainlp.util.wordtonum import text_to_num, thaiword_to_num, words_to_num
131+
132+
# sound_syllable and pronounce have to be imported last,
133+
# to prevent circular import issues.
134+
# Other imports should be above this line, sorted.
135+
from pythainlp.util.syllable import (
136+
sound_syllable,
137+
syllable_length,
138+
syllable_open_close_detector,
139+
tone_detector,
140+
)
141+
from pythainlp.util.pronounce import (
142+
rhyme,
143+
spelling,
144+
thai_consonant_to_spelling,
145+
tone_to_spelling,
146+
)

0 commit comments

Comments
 (0)