From 4454bc344e665b3a8801f428b8df5da719b2606f Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 26 Aug 2019 15:53:57 +0700 Subject: [PATCH] Lint --- src/stdio_mgr/stdio_mgr.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/stdio_mgr/stdio_mgr.py b/src/stdio_mgr/stdio_mgr.py index 0840315..5b2f691 100644 --- a/src/stdio_mgr/stdio_mgr.py +++ b/src/stdio_mgr/stdio_mgr.py @@ -276,20 +276,21 @@ class SafeCloseTeeStdin(_SafeCloseIOBase, TeeStdin): class TupleContextManager(tuple, AbstractContextManager): - pass + """Base for context managers that are also a tuple.""" + # This is needed to establish a workable MRO. class StdioTuple(TupleContextManager): - """Tuple of stdin, stdout and stderr streams.""" + """Tuple context manager of stdin, stdout and stderr streams.""" def __new__(cls, iterable): + """Instantiate new tuple from iterable constaining three TextIOBase.""" items = list(iterable) - assert len(items) == 3 + assert len(items) == 3 # noqa: S101 # pytest and colorama break this assertion when applied to the sys.foo # when they replace them with custom objects, and probably many other # similar tools do the same - # assert all(isinstance(item, TextIOBase) for item in items), \ - # list(type(item) for item in items) + # assert all(isinstance(item, TextIOBase) for item in items) # noqa: E800 return super(StdioTuple, cls).__new__(cls, items) @@ -341,6 +342,7 @@ class FakeStdioTuple(StdioTuple, _MultiCloseContextManager): """ def __new__(cls, in_str="", close=True): + """Instantiate new tuple of fake stdin, stdout and stderr.""" if close: out_cls = SafeCloseRandomTextIO in_cls = SafeCloseTeeStdin @@ -359,6 +361,7 @@ class CurrentSysIoStreams(StdioTuple): """Tuple of current stdin, stdout and stderr streams.""" def __new__(cls): + """Instantiate new tuple of current sys.stdin, sys.stdout and sys.stderr.""" items = [sys.stdin, sys.stdout, sys.stderr] return super(CurrentSysIoStreams, cls).__new__(cls, items) @@ -377,7 +380,7 @@ class StdioManager(_MultiCloseContextManager): """ def __new__(cls, in_str="", close=True, streams=None): - """Instantiate new context manager that emulates namedtuple.""" + """Instantiate new context manager for streams.""" if not streams: streams = FakeStdioTuple(in_str, close)