summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-05 14:05:58 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-05 14:05:58 +0200
commit992aecee297f7fe781eddc715fff6d7f5bbed875 (patch)
tree459eb2100b39f76c80da993970681ac4ab3196a9 /main.py
parent30d97ce8eb9085cff432e89360e8b377cb81f3be (diff)
downloadruamel.yaml-992aecee297f7fe781eddc715fff6d7f5bbed875.tar.gz
Fixes issue #215, adding Union[Path, StreamType]
*When this change indeed resolves your problem, please **Close** this issue*. *(You can do so usingthe WorkFlow pull-down (close to the top right of this page)*
Diffstat (limited to 'main.py')
-rw-r--r--main.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.py b/main.py
index 93c89ca..510650e 100644
--- a/main.py
+++ b/main.py
@@ -37,6 +37,10 @@ from ruamel.yaml.loader import Loader as UnsafeLoader
if False: # MYPY
from typing import List, Set, Dict, Union, Any # NOQA
from ruamel.yaml.compat import StreamType, StreamTextType, VersionType # NOQA
+ if PY3:
+ from pathlib import Path
+ else:
+ Path = Any
try:
from _ruamel_yaml import CParser, CEmitter # type: ignore
@@ -279,7 +283,7 @@ class YAML(object):
# separate output resolver?
def load(self, stream):
- # type: (StreamTextType) -> Any
+ # type: (Union[Path, StreamTextType]) -> Any
"""
at this point you either have the non-pure Parser (which has its own reader and
scanner) or you have the pure Parser.
@@ -306,7 +310,7 @@ class YAML(object):
pass
def load_all(self, stream, _kw=enforce): # , skip=None):
- # type: (StreamTextType, Any) -> Any
+ # type: (Union[Path, StreamTextType], Any) -> Any
if _kw is not enforce:
raise TypeError(
'{}.__init__() takes no positional argument but at least '
@@ -383,11 +387,11 @@ class YAML(object):
return self.constructor, self.parser
def dump(self, data, stream, _kw=enforce, transform=None):
- # type: (Any, StreamType, Any, Any) -> Any
+ # type: (Any, Union[Path, StreamType], Any, Any) -> Any
return self.dump_all([data], stream, _kw, transform=transform)
def dump_all(self, documents, stream, _kw=enforce, transform=None):
- # type: (Any, StreamType, Any, Any) -> Any
+ # type: (Any, Union[Path, StreamType], Any, Any) -> Any
"""
Serialize a sequence of Python objects into a YAML stream.
"""