mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Migrate to py3 style type annotation: sphinx.util
This commit is contained in:
parent
60b1cec446
commit
9c5b26756a
@ -337,15 +337,13 @@ _coding_re = re.compile(r'coding[:=]\s*([-\w.]+)')
|
||||
def detect_encoding(readline: Callable[[], bytes]) -> str:
|
||||
"""Like tokenize.detect_encoding() from Py3k, but a bit simplified."""
|
||||
|
||||
def read_or_stop():
|
||||
# type: () -> bytes
|
||||
def read_or_stop() -> bytes:
|
||||
try:
|
||||
return readline()
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
def get_normal_name(orig_enc):
|
||||
# type: (str) -> str
|
||||
def get_normal_name(orig_enc: str) -> str:
|
||||
"""Imitates get_normal_name in tokenizer.c."""
|
||||
# Only care about the first 12 characters.
|
||||
enc = orig_enc[:12].lower().replace('_', '-')
|
||||
@ -356,8 +354,7 @@ def detect_encoding(readline: Callable[[], bytes]) -> str:
|
||||
return 'iso-8859-1'
|
||||
return orig_enc
|
||||
|
||||
def find_cookie(line):
|
||||
# type: (bytes) -> str
|
||||
def find_cookie(line: bytes) -> str:
|
||||
try:
|
||||
line_string = line.decode('ascii')
|
||||
except UnicodeDecodeError:
|
||||
|
Loading…
Reference in New Issue
Block a user