diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-12-15 03:14:11 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-12-15 23:57:43 +0900 |
commit | 6bc357140dbb074eb0d590c1226009f83f97862e (patch) | |
tree | a7c8d2087ee1f50dadb5ca78343ac10c6959b740 /sphinx/cmd/quickstart.py | |
parent | 0031c9b4822ae9684888ae90bc70d6ceb3313581 (diff) | |
download | sphinx-git-6bc357140dbb074eb0d590c1226009f83f97862e.tar.gz |
Replace all "unicode" type by "str"
Diffstat (limited to 'sphinx/cmd/quickstart.py')
-rw-r--r-- | sphinx/cmd/quickstart.py | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py index f313942b9..ce66f7352 100644 --- a/sphinx/cmd/quickstart.py +++ b/sphinx/cmd/quickstart.py @@ -50,7 +50,6 @@ from sphinx.util.template import SphinxRenderer if False: # For type annotation from typing import Any, Callable, Dict, List, Pattern, Union # NOQA - from sphinx.util.typing import unicode # NOQA TERM_ENCODING = getattr(sys.stdin, 'encoding', None) @@ -91,7 +90,7 @@ else: # function to get input from terminal -- overridden by the test suite def term_input(prompt): - # type: (unicode) -> unicode + # type: (str) -> str if sys.platform == 'win32': # Important: On windows, readline is not enabled by default. In these # environment, escape sequences have been broken. To avoid the @@ -107,7 +106,7 @@ class ValidationError(Exception): def is_path(x): - # type: (unicode) -> unicode + # type: (str) -> str x = path.expanduser(x) if not path.isdir(x): raise ValidationError(__("Please enter a valid path name.")) @@ -115,21 +114,21 @@ def is_path(x): def allow_empty(x): - # type: (unicode) -> unicode + # type: (str) -> str return x def nonempty(x): - # type: (unicode) -> unicode + # type: (str) -> str if not x: raise ValidationError(__("Please enter some text.")) return x def choice(*l): - # type: (unicode) -> Callable[[unicode], unicode] + # type: (str) -> Callable[[str], str] def val(x): - # type: (unicode) -> unicode + # type: (str) -> str if x not in l: raise ValidationError(__('Please enter one of %s.') % ', '.join(l)) return x @@ -137,14 +136,14 @@ def choice(*l): def boolean(x): - # type: (unicode) -> bool + # type: (str) -> bool if x.upper() not in ('Y', 'YES', 'N', 'NO'): raise ValidationError(__("Please enter either 'y' or 'n'.")) return x.upper() in ('Y', 'YES') def suffix(x): - # type: (unicode) -> unicode + # type: (str) -> str if not (x[0:1] == '.' and len(x) > 1): raise ValidationError(__("Please enter a file suffix, " "e.g. '.rst' or '.txt'.")) @@ -152,12 +151,12 @@ def suffix(x): def ok(x): - # type: (unicode) -> unicode + # type: (str) -> str return x def term_decode(text): - # type: (Union[bytes,unicode]) -> unicode + # type: (Union[bytes,str]) -> str if isinstance(text, text_type): return text @@ -179,10 +178,10 @@ def term_decode(text): def do_prompt(text, default=None, validator=nonempty): - # type: (unicode, unicode, Callable[[unicode], Any]) -> Union[unicode, bool] + # type: (str, str, Callable[[str], Any]) -> Union[str, bool] while True: if default is not None: - prompt = PROMPT_PREFIX + '%s [%s]: ' % (text, default) # type: unicode + prompt = PROMPT_PREFIX + '%s [%s]: ' % (text, default) else: prompt = PROMPT_PREFIX + text + ': ' if USE_LIBEDIT: @@ -206,7 +205,7 @@ def do_prompt(text, default=None, validator=nonempty): def convert_python_source(source, rex=re.compile(r"[uU]('.*?')")): - # type: (unicode, Pattern) -> unicode + # type: (str, Pattern) -> str # remove Unicode literal prefixes warnings.warn('convert_python_source() is deprecated.', RemovedInSphinx40Warning) @@ -215,12 +214,12 @@ def convert_python_source(source, rex=re.compile(r"[uU]('.*?')")): class QuickstartRenderer(SphinxRenderer): def __init__(self, templatedir): - # type: (unicode) -> None + # type: (str) -> None self.templatedir = templatedir or '' super(QuickstartRenderer, self).__init__() def render(self, template_name, context): - # type: (unicode, Dict) -> unicode + # type: (str, Dict) -> str user_template = path.join(self.templatedir, path.basename(template_name)) if self.templatedir and path.exists(user_template): return self.render_from_file(user_template, context) @@ -373,7 +372,7 @@ directly.''')) def generate(d, overwrite=True, silent=False, templatedir=None): - # type: (Dict, bool, bool, unicode) -> None + # type: (Dict, bool, bool, str) -> None """Generate project based on values in *d*.""" template = QuickstartRenderer(templatedir=templatedir) @@ -425,7 +424,7 @@ def generate(d, overwrite=True, silent=False, templatedir=None): ensuredir(path.join(srcdir, d['dot'] + 'static')) def write_file(fpath, content, newline=None): - # type: (unicode, unicode, unicode) -> None + # type: (str, str, str) -> None if overwrite or not path.isfile(fpath): if 'quiet' not in d: print(__('Creating file %s.') % fpath) |