@@ -85,10 +85,11 @@ def __init__(
8585
8686 self .__cmd = cmd
8787 if isinstance (stdin , six .binary_type ):
88- stdin = self ._get_str_from_bin (bytearray (stdin ))
88+ self . __stdin = self ._get_str_from_bin (bytearray (stdin )) # type: typing.Optional[typing.Text]
8989 elif isinstance (stdin , bytearray ):
90- stdin = self ._get_str_from_bin (stdin )
91- self .__stdin = stdin # type: typing.Optional[typing.Text]
90+ self .__stdin = self ._get_str_from_bin (stdin )
91+ else :
92+ self .__stdin = stdin
9293
9394 if stdout is not None :
9495 self ._stdout = tuple (stdout ) # type: typing.Tuple[bytes, ...]
@@ -107,10 +108,10 @@ def __init__(
107108 self .__started = started # type: typing.Optional[datetime.datetime]
108109
109110 # By default is none:
110- self ._stdout_str = None
111- self ._stderr_str = None
112- self ._stdout_brief = None
113- self ._stderr_brief = None
111+ self ._stdout_str = None # type: typing.Optional[typing.Text]
112+ self ._stderr_str = None # type: typing.Optional[typing.Text]
113+ self ._stdout_brief = None # type: typing.Optional[typing.Text]
114+ self ._stderr_brief = None # type: typing.Optional[typing.Text]
114115
115116 @property
116117 def stdout_lock (self ): # type: () -> threading.RLock
@@ -176,7 +177,7 @@ def _get_str_from_bin(src): # type: (bytearray) -> typing.Text
176177 return src .strip ().decode (encoding = "utf-8" , errors = "backslashreplace" )
177178
178179 @classmethod
179- def _get_brief (cls , data ): # type: (typing.Tuple[bytes]) -> typing.Text
180+ def _get_brief (cls , data ): # type: (typing.Tuple[bytes, ... ]) -> typing.Text
180181 """Get brief output: 7 lines maximum (3 first + ... + 3 last).
181182
182183 :param data: source to process
@@ -228,7 +229,7 @@ def _poll_stream(
228229 log = None , # type: typing.Optional[logging.Logger]
229230 verbose = False , # type: bool
230231 ): # type: (...) -> typing.List[bytes]
231- dst = []
232+ dst = [] # type: typing.List[bytes]
232233 try :
233234 for line in src :
234235 dst .append (line )
@@ -323,8 +324,8 @@ def stdout_str(self): # type: () -> typing.Text
323324 """
324325 with self .stdout_lock :
325326 if self ._stdout_str is None :
326- self ._stdout_str = self ._get_str_from_bin (self .stdout_bin ) # type: ignore
327- return self ._stdout_str # type: ignore
327+ self ._stdout_str = self ._get_str_from_bin (self .stdout_bin )
328+ return self ._stdout_str
328329
329330 @property
330331 def stderr_str (self ): # type: () -> typing.Text
@@ -334,8 +335,8 @@ def stderr_str(self): # type: () -> typing.Text
334335 """
335336 with self .stderr_lock :
336337 if self ._stderr_str is None :
337- self ._stderr_str = self ._get_str_from_bin (self .stderr_bin ) # type: ignore
338- return self ._stderr_str # type: ignore
338+ self ._stderr_str = self ._get_str_from_bin (self .stderr_bin )
339+ return self ._stderr_str
339340
340341 @property
341342 def stdout_brief (self ): # type: () -> typing.Text
@@ -345,8 +346,8 @@ def stdout_brief(self): # type: () -> typing.Text
345346 """
346347 with self .stdout_lock :
347348 if self ._stdout_brief is None :
348- self ._stdout_brief = self ._get_brief (self .stdout ) # type: ignore
349- return self ._stdout_brief # type: ignore
349+ self ._stdout_brief = self ._get_brief (self .stdout )
350+ return self ._stdout_brief
350351
351352 @property
352353 def stderr_brief (self ): # type: () -> typing.Text
@@ -356,8 +357,8 @@ def stderr_brief(self): # type: () -> typing.Text
356357 """
357358 with self .stderr_lock :
358359 if self ._stderr_brief is None :
359- self ._stderr_brief = self ._get_brief (self .stderr ) # type: ignore
360- return self ._stderr_brief # type: ignore
360+ self ._stderr_brief = self ._get_brief (self .stderr )
361+ return self ._stderr_brief
361362
362363 @property
363364 def exit_code (self ): # type: () -> typing.Union[int, proc_enums.ExitCodes]
@@ -382,7 +383,7 @@ def exit_code(self, new_val): # type: (typing.Union[int, proc_enums.ExitCodes])
382383 if self .timestamp :
383384 raise RuntimeError ("Exit code is already received." )
384385 if not isinstance (new_val , (six .integer_types , proc_enums .ExitCodes )):
385- raise TypeError ("Exit code is strictly int, got { !r}" .format (new_val ))
386+ raise TypeError ("Exit code is strictly int, received: {code !r}" .format (code = new_val ))
386387 with self .stdout_lock , self .stderr_lock :
387388 self .__exit_code = proc_enums .exit_code_to_enum (new_val )
388389 if self .__exit_code != proc_enums .INVALID :
0 commit comments