From caaca557fccfa4ebdab77ede282b4a0ef1cb6480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Fri, 18 Dec 2020 22:24:19 +0100 Subject: [PATCH] Fix typing of the Pinyin's data_path argument --- src/xpinyin/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/xpinyin/__init__.py b/src/xpinyin/__init__.py index c59ec51..3b7aba8 100644 --- a/src/xpinyin/__init__.py +++ b/src/xpinyin/__init__.py @@ -56,8 +56,9 @@ class Pinyin: data_path = Path(__file__).resolve().with_name('Mandarin.dat') - def __init__(self, data_path: str = data_path) -> None: - self.pinyins = dict(tuple(line.split('\t', maxsplit=1)) for line in data_path.read_text().splitlines()) + def __init__(self, data_path: str = str(data_path)) -> None: + lines = Path(data_path).read_text().splitlines() + self.pinyins = dict(tuple(line.split('\t', maxsplit=1)) for line in lines) @staticmethod def decode_pinyin(s: str) -> str: