1
0
forked from AFPy/pospell

Pleases pylint and mypy.

This commit is contained in:
Julien Palard 2021-10-27 17:22:08 +02:00
parent 1525acad68
commit 6c8779826a
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
3 changed files with 10 additions and 8 deletions

View File

@ -36,7 +36,7 @@ class Unreachable(POSpellException):
try:
HUNSPELL_VERSION = subprocess.check_output(
["hunspell", "--version"], universal_newlines=True
).split("\n")[0]
).split("\n", maxsplit=1)[0]
except FileNotFoundError:
print("hunspell not found, please install hunspell.", file=sys.stderr)
sys.exit(1)
@ -216,7 +216,7 @@ def po_to_text(po_path, drop_capitalized=False):
buffer = []
lines = 0
try:
entries = polib.pofile(Path(po_path).read_text())
entries = polib.pofile(Path(po_path).read_text(encoding="UTF-8"))
except Exception as err:
raise POSpellException(str(err)) from err
for entry in entries:
@ -410,18 +410,16 @@ def gracefull_handling_of_missing_dicts(language):
)
if which("apt"):
error("Maybe try something like:")
error(" sudo apt install hunspell-{}".format(language))
error(f" sudo apt install hunspell-{language}")
else:
error(
"""I don't know your environment, but I bet the package name looks like:
f"""I don't know your environment, but I bet the package name looks like:
hunspell-{language}
If you find it, please tell me (by opening an issue or a PR on
https://github.com/JulienPalard/pospell/) so I can enhance this error message.
""".format(
language=language
)
"""
)
sys.exit(1)

View File

@ -25,6 +25,7 @@ classifiers =
[options]
py_modules = pospell
python_requires = >= 3.6
install_requires = polib; docutils>=0.11,<0.18; regex
[options.entry_points]

View File

@ -54,7 +54,10 @@ skip_install = True
commands = black --check --diff tests/ pospell.py
[testenv:mypy]
deps = mypy
deps =
mypy
types-docutils
types-polib
skip_install = True
commands = mypy --ignore-missing-imports pospell.py