summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaz Solc <tomaz.solc@tablix.org>2021-02-05 13:27:04 +0100
committerTomaz Solc <tomaz.solc@tablix.org>2021-02-05 13:27:04 +0100
commit917aa99ba5e37a175f3453a545d12f9b37ef7bdd (patch)
tree23476f4702e4b907e632bf7546c60db7631aa51f
parent171184d5a3162bfcbba8961a2d8c6e1b6694c406 (diff)
downloadunidecode-917aa99ba5e37a175f3453a545d12f9b37ef7bdd.tar.gz
Move Py3.5-compatible type annotations inline.
-rw-r--r--unidecode/__init__.py7
-rw-r--r--unidecode/__init__.pyi5
2 files changed, 4 insertions, 8 deletions
diff --git a/unidecode/__init__.py b/unidecode/__init__.py
index aeb24e0..20a8c43 100644
--- a/unidecode/__init__.py
+++ b/unidecode/__init__.py
@@ -18,11 +18,12 @@ b'Knosos'
"""
import warnings
from sys import version_info
+from typing import Optional
Cache = {}
class UnidecodeError(ValueError):
- def __init__(self, message, index=None):
+ def __init__(self, message: str, index: Optional[int] = None) -> None:
"""Raised for Unidecode-related errors.
The index attribute contains the index of the character that caused
@@ -32,7 +33,7 @@ class UnidecodeError(ValueError):
self.index = index
-def unidecode_expect_ascii(string, errors='ignore', replace_str='?'):
+def unidecode_expect_ascii(string: str, errors: str = 'ignore', replace_str: str = '?') -> str:
"""Transliterate an Unicode object into an ASCII string
>>> unidecode("\u5317\u4EB0")
@@ -65,7 +66,7 @@ def unidecode_expect_ascii(string, errors='ignore', replace_str='?'):
return _unidecode(string, errors, replace_str)
-def unidecode_expect_nonascii(string, errors='ignore', replace_str='?'):
+def unidecode_expect_nonascii(string: str, errors: str = 'ignore', replace_str: str = '?') -> str:
"""Transliterate an Unicode object into an ASCII string
>>> unidecode("\u5317\u4EB0")
diff --git a/unidecode/__init__.pyi b/unidecode/__init__.pyi
index 5963674..e3889ca 100644
--- a/unidecode/__init__.pyi
+++ b/unidecode/__init__.pyi
@@ -4,8 +4,3 @@ Cache: Dict[int, Optional[Sequence[Optional[str]]]]
class UnidecodeError(ValueError):
index: Optional[int] = ...
- def __init__(self, message: str, index: Optional[int] = ...) -> None: ...
-
-def unidecode_expect_ascii(string: str, errors: str = ..., replace_str: str = ...) -> str: ...
-def unidecode_expect_nonascii(string: str, errors: str = ..., replace_str: str = ...) -> str: ...
-unidecode = unidecode_expect_ascii