@@ -368,7 +368,7 @@ def __init__(self, targetfd: int) -> None:
368368 self .targetfd_save = os .dup (targetfd )
369369
370370 if targetfd == 0 :
371- self .tmpfile = open (os .devnull , encoding = "utf-8" )
371+ self .tmpfile = open (os .devnull , encoding = "utf-8" ) # noqa: SIM115
372372 self .syscapture = SysCapture (targetfd )
373373 else :
374374 self .tmpfile = EncodedFile (
@@ -494,9 +494,7 @@ class CaptureResult(Generic[AnyStr]):
494494 This class was a namedtuple, but due to mypy limitation [0]_ it could not be made
495495 generic, so was replaced by a regular class which tries to emulate the pertinent
496496 parts of a namedtuple. If the mypy limitation is ever lifted, can make it a
497- namedtuple again.
498-
499- .. [0] https://github.com/python/mypy/issues/685
497+ namedtuple again (https://github.com/python/mypy/issues/685).
500498
501499 """
502500
@@ -512,7 +510,7 @@ def __len__(self) -> int:
512510 def __iter__ (self ) -> Iterator [AnyStr ]:
513511 return iter ((self .out , self .err ))
514512
515- def __getitem__ (self , item : int ) -> AnyStr : # noqa: ARG002
513+ def __getitem__ (self , item : int ) -> AnyStr :
516514 return tuple (self )[item ]
517515
518516 def _replace (
@@ -634,14 +632,8 @@ def is_started(self) -> bool:
634632 return self ._state == "started"
635633
636634 def readouterr (self ) -> CaptureResult [AnyStr ]:
637- if self .out :
638- out = self .out .snap ()
639- else :
640- out = ""
641- if self .err :
642- err = self .err .snap ()
643- else :
644- err = ""
635+ out = self .out .snap () if self .out else ""
636+ err = self .err .snap () if self .err else ""
645637 return CaptureResult (out , err ) # type: ignore
646638
647639
0 commit comments