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/directives/code.py | |
parent | 0031c9b4822ae9684888ae90bc70d6ceb3313581 (diff) | |
download | sphinx-git-6bc357140dbb074eb0d590c1226009f83f97862e.tar.gz |
Replace all "unicode" type by "str"
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 914d5d4b0..05dafb623 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -29,7 +29,6 @@ if False: from typing import Any, Dict, List, Tuple # NOQA from sphinx.application import Sphinx # NOQA from sphinx.config import Config # NOQA - from sphinx.util.typing import unicode # NOQA logger = logging.getLogger(__name__) @@ -67,7 +66,7 @@ class HighlightLang(Highlight): def dedent_lines(lines, dedent, location=None): - # type: (List[unicode], int, Any) -> List[unicode] + # type: (List[str], int, Any) -> List[str] if not dedent: return lines @@ -85,7 +84,7 @@ def dedent_lines(lines, dedent, location=None): def container_wrapper(directive, literal_node, caption): - # type: (SphinxDirective, nodes.Node, unicode) -> nodes.container + # type: (SphinxDirective, nodes.Node, str) -> nodes.container container_node = nodes.container('', literal_block=True, classes=['literal-block-wrapper']) parsed = nodes.Element() @@ -198,7 +197,7 @@ class LiteralIncludeReader: ] def __init__(self, filename, options, config): - # type: (unicode, Dict, Config) -> None + # type: (str, Dict, Config) -> None self.filename = filename self.options = options self.encoding = options.get('encoding', config.source_encoding) @@ -214,10 +213,10 @@ class LiteralIncludeReader: (option1, option2)) def read_file(self, filename, location=None): - # type: (unicode, Any) -> List[unicode] + # type: (str, Any) -> List[str] try: with open(filename, encoding=self.encoding, errors='strict') as f: - text = f.read() # type: unicode + text = f.read() if 'tab-width' in self.options: text = text.expandtabs(self.options['tab-width']) @@ -230,7 +229,7 @@ class LiteralIncludeReader: (self.encoding, filename)) def read(self, location=None): - # type: (Any) -> Tuple[unicode, int] + # type: (Any) -> Tuple[str, int] if 'diff' in self.options: lines = self.show_diff() else: @@ -248,7 +247,7 @@ class LiteralIncludeReader: return ''.join(lines), len(lines) def show_diff(self, location=None): - # type: (Any) -> List[unicode] + # type: (Any) -> List[str] new_lines = self.read_file(self.filename) old_filename = self.options.get('diff') old_lines = self.read_file(old_filename) @@ -256,7 +255,7 @@ class LiteralIncludeReader: return list(diff) def pyobject_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] pyobject = self.options.get('pyobject') if pyobject: from sphinx.pycode import ModuleAnalyzer @@ -275,7 +274,7 @@ class LiteralIncludeReader: return lines def lines_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] linespec = self.options.get('lines') if linespec: linelist = parselinenos(linespec, len(lines)) @@ -300,7 +299,7 @@ class LiteralIncludeReader: return lines def start_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] if 'start-at' in self.options: start = self.options.get('start-at') inclusive = False @@ -332,7 +331,7 @@ class LiteralIncludeReader: return lines def end_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] if 'end-at' in self.options: end = self.options.get('end-at') inclusive = True @@ -360,7 +359,7 @@ class LiteralIncludeReader: return lines def prepend_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] prepend = self.options.get('prepend') if prepend: lines.insert(0, prepend + '\n') @@ -368,7 +367,7 @@ class LiteralIncludeReader: return lines def append_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] append = self.options.get('append') if append: lines.append(append + '\n') @@ -376,7 +375,7 @@ class LiteralIncludeReader: return lines def dedent_filter(self, lines, location=None): - # type: (List[unicode], Any) -> List[unicode] + # type: (List[str], Any) -> List[str] if 'dedent' in self.options: return dedent_lines(lines, self.options.get('dedent'), location=location) else: @@ -470,7 +469,7 @@ class LiteralInclude(SphinxDirective): def setup(app): - # type: (Sphinx) -> Dict[unicode, Any] + # type: (Sphinx) -> Dict[str, Any] directives.register_directive('highlight', Highlight) directives.register_directive('highlightlang', HighlightLang) directives.register_directive('code-block', CodeBlock) |