(
phrase: str,
msg: str,
in_aspell: Optional[bool],
fname: str,
languages: Iterable[str],
)
| 100 | |
| 101 | |
| 102 | def _check_aspell( |
| 103 | phrase: str, |
| 104 | msg: str, |
| 105 | in_aspell: Optional[bool], |
| 106 | fname: str, |
| 107 | languages: Iterable[str], |
| 108 | ) -> None: |
| 109 | if not spellers: # if no spellcheckers exist |
| 110 | return # cannot check |
| 111 | if in_aspell is None: |
| 112 | return # don't check |
| 113 | if " " in phrase: |
| 114 | for word in phrase.split(): |
| 115 | _check_aspell(word, msg, in_aspell, fname, languages) |
| 116 | return # stop normal checking as we've done each word above |
| 117 | this_in_aspell = any( |
| 118 | spellers[lang].check(phrase.encode(spellers[lang].ConfigKeys()["encoding"][1])) |
| 119 | for lang in languages |
| 120 | ) |
| 121 | end = f"be in aspell dictionaries ({', '.join(languages)}) for dictionary {fname}" |
| 122 | if in_aspell: # should be an error in aspell |
| 123 | assert this_in_aspell, f"{msg} should {end}" |
| 124 | else: # shouldn't be |
| 125 | assert not this_in_aspell, f"{msg} should not {end}" |
| 126 | |
| 127 | |
| 128 | whitespace = re.compile(r"\s") |
no outgoing calls
no test coverage detected
searching dependent graphs…