Skip to content

Commit

Permalink
Merge pull request #699 from prospector-dev/fix-direct-tool-stdout
Browse files Browse the repository at this point in the history
Fix --direct-tool-stdout
  • Loading branch information
sbrunner authored Nov 12, 2024
2 parents 103b147 + f238046 commit 16e51c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion prospector/tools/ruff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def configure(self, prospector_config: "ProspectorConfig", _: Any) -> None:
self.ruff_args.append(f"--{key}={value}")

def run(self, found_files: FileFinder) -> list[Message]:
print([self.ruff_bin, *self.ruff_args])
messages = []
completed_process = subprocess.run( # noqa: S603
[self.ruff_bin, *self.ruff_args, *found_files.python_modules], capture_output=True
Expand Down
10 changes: 4 additions & 6 deletions prospector/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def flush(self) -> None:

class CaptureOutput:
_prev_streams = None
stdout: Optional[TextIOWrapper] = None
stderr: Optional[TextIOWrapper] = None
stdout: Optional[CaptureStream] = None
stderr: Optional[CaptureStream] = None

def __init__(self, hide: bool) -> None:
self.hide = hide
Expand All @@ -41,12 +41,10 @@ def __enter__(self) -> "CaptureOutput":
return self

def get_hidden_stdout(self) -> str:
assert isinstance(self.stdout, CaptureStream)
return self.stdout.contents
return "" if self.stdout is None else self.stdout.contents

def get_hidden_stderr(self) -> str:
assert isinstance(self.stderr, CaptureStream)
return self.stderr.contents
return "" if self.stderr is None else self.stderr.contents

def __exit__(self, exc_type: type, exc_val: Exception, exc_tb: type) -> None:
if self.hide:
Expand Down

0 comments on commit 16e51c0

Please sign in to comment.