-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[refactor] increase consistency in stdout and stderr optional arguments #19638
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
base: master
Are you sure you want to change the base?
Changes from all commits
f08e730
cf0de50
f390f25
ba3641f
5cfcbc4
b040095
ad9b9c1
7e16ac4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -592,7 +592,11 @@ class FancyFormatter: | |
""" | ||
|
||
def __init__( | ||
self, f_out: IO[str], f_err: IO[str], hide_error_codes: bool, hide_success: bool = False | ||
self, | ||
f_out: IO[str] | None, | ||
f_err: IO[str] | None, | ||
hide_error_codes: bool, | ||
hide_success: bool = False, | ||
) -> None: | ||
self.hide_error_codes = hide_error_codes | ||
self.hide_success = hide_success | ||
|
@@ -601,7 +605,11 @@ def __init__( | |
if sys.platform not in ("linux", "darwin", "win32", "emscripten"): | ||
self.dummy_term = True | ||
return | ||
if not should_force_color() and (not f_out.isatty() or not f_err.isatty()): | ||
if ( | ||
(f_out is None or f_err is None) | ||
or not should_force_color() | ||
and (not f_out.isatty() or not f_err.isatty()) | ||
): | ||
self.dummy_term = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure whether it matters whether or not it's a dummy term if stdout or stderr are None, but since None means no printing I figured that's a pretty dummy term... (In case it's not clear: the only reason I included the check for None is because python has no safe navigation operator that would let us go There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check could also be distributed like if not should_force_color() and (not (f_out and f_out.isatty()) or not (f_err and f_err.isatty())) I have no strong feelings on that. |
||
return | ||
if sys.platform == "win32": | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this one directly use sys.stderr? I don't know, probably some reason. It was like that when I got here.