diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-05 23:20:17 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-05 23:20:17 +0200 |
commit | bfd63d6184e3a43cb63e0831467819bc44513d50 (patch) | |
tree | 9426b3c93cb1fd7849ea678424b6bbd900ff2d68 /emitter.py | |
parent | 893db272efb6d7041e09aa09f04da2010ec92072 (diff) | |
download | ruamel.yaml-bfd63d6184e3a43cb63e0831467819bc44513d50.tar.gz |
added context manager, mypy cleanup (w. Optional) added tests0.15.50
Diffstat (limited to 'emitter.py')
-rw-r--r-- | emitter.py | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -20,7 +20,7 @@ from ruamel.yaml.compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ # fmt: on if False: # MYPY - from typing import Any, Dict, List, Union, Text, Tuple # NOQA + from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from ruamel.yaml.compat import StreamType # NOQA __all__ = ['Emitter', 'EmitterError'] @@ -113,14 +113,14 @@ class Emitter(object): prefix_colon=None, dumper=None, ): - # type: (StreamType, Any, Union[None, int], Union[None, int], Union[None, bool], Any, Union[None, int], Union[None, bool], Any, Any) -> None # NOQA + # type: (StreamType, Any, Optional[int], Optional[int], Optional[bool], Any, Optional[int], Optional[bool], Any, Any) -> None # NOQA self.dumper = dumper if self.dumper is not None and getattr(self.dumper, '_emitter', None) is None: self.dumper._emitter = self self.stream = stream # Encoding can be overriden by STREAM-START. - self.encoding = None # type: Union[None, Text] + self.encoding = None # type: Optional[Text] self.allow_space_break = None # Emitter is a state machine with a stack of states to handle nested @@ -134,7 +134,7 @@ class Emitter(object): # The current indentation level and the stack of previous indents. self.indents = Indents() - self.indent = None # type: Union[None, int] + self.indent = None # type: Optional[int] # Flow level. self.flow_level = 0 @@ -154,7 +154,7 @@ class Emitter(object): self.column = 0 self.whitespace = True self.indention = True - self.no_newline = None # type: Union[None, bool] # set if directly after `- ` + self.no_newline = None # type: Optional[bool] # set if directly after `- ` # Whether the document requires an explicit document indicator self.open_ended = False @@ -269,7 +269,7 @@ class Emitter(object): return len(self.events) < count + 1 def increase_indent(self, flow=False, sequence=None, indentless=False): - # type: (bool, Union[None, bool], bool) -> None + # type: (bool, Optional[bool], bool) -> None self.indents.append(self.indent, sequence) if self.indent is None: # top level if flow: |