diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-11-08 14:05:58 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-11-16 12:06:22 +0900 |
commit | ceec82451bfbefc0fd720bbf48e4b9a029cacd99 (patch) | |
tree | 1d76b5d59db131fb574cd649e0c283534fd6710f /sphinx/cmdline.py | |
parent | 3407ef0ca8a8ce41e67092d2605f8fc77bebb982 (diff) | |
download | sphinx-git-ceec82451bfbefc0fd720bbf48e4b9a029cacd99.tar.gz |
Add type-check annotations to sphinx.*
Diffstat (limited to 'sphinx/cmdline.py')
-rw-r--r-- | sphinx/cmdline.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py index 0d85767e4..7a97e10e2 100644 --- a/sphinx/cmdline.py +++ b/sphinx/cmdline.py @@ -16,17 +16,22 @@ import traceback from os import path from six import text_type, binary_type + from docutils.utils import SystemMessage from sphinx import __display_version__ from sphinx.errors import SphinxError from sphinx.application import Sphinx from sphinx.util import Tee, format_exception_cut_frames, save_traceback -from sphinx.util.console import red, nocolor, color_terminal +from sphinx.util.console import red, nocolor, color_terminal # type: ignore from sphinx.util.docutils import docutils_namespace from sphinx.util.osutil import abspath, fs_encoding from sphinx.util.pycompat import terminal_safe +if False: + # For type annotation + from typing import Any, IO, Union # NOQA + USAGE = """\ Sphinx v%s @@ -45,18 +50,21 @@ For more information, visit <http://sphinx-doc.org/>. class MyFormatter(optparse.IndentedHelpFormatter): def format_usage(self, usage): + # type: (Any) -> Any return usage def format_help(self, formatter): - result = [] - if self.description: + # type: (Any) -> unicode + result = [] # type: List[unicode] + if self.description: # type: ignore result.append(self.format_description(formatter)) - if self.option_list: - result.append(self.format_option_help(formatter)) + if self.option_list: # type: ignore + result.append(self.format_option_help(formatter)) # type: ignore return "\n".join(result) def handle_exception(app, opts, exception, stderr=sys.stderr): + # type: (Sphinx, Any, Union[Exception, KeyboardInterrupt], IO) -> None if opts.pdb: import pdb print(red('Exception occurred while building, starting debugger:'), @@ -107,6 +115,7 @@ def handle_exception(app, opts, exception, stderr=sys.stderr): def main(argv): + # type: (List[unicode]) -> int if not color_terminal(): nocolor() @@ -210,11 +219,11 @@ def main(argv): # handle remaining filename arguments filenames = args[2:] - err = 0 + err = 0 # type: ignore for filename in filenames: if not path.isfile(filename): print('Error: Cannot find file %r.' % filename, file=sys.stderr) - err = 1 + err = 1 # type: ignore if err: return 1 @@ -249,7 +258,7 @@ def main(argv): print('Error: Cannot open warning file %r: %s' % (opts.warnfile, exc), file=sys.stderr) sys.exit(1) - warning = Tee(warning, warnfp) + warning = Tee(warning, warnfp) # type: ignore error = warning confoverrides = {} |