Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --direct-tool-stdout #699

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading