Skip to content

odb.git: Send captured-but-discarded output to DEVNULL#99

Merged
mystor merged 5 commits into
mystor:mainfrom
rwe:devnull
Feb 5, 2022
Merged

odb.git: Send captured-but-discarded output to DEVNULL#99
mystor merged 5 commits into
mystor:mainfrom
rwe:devnull

Conversation

@rwe

@rwe rwe commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

This avoids buffering captured output that's always discarded. The parameter change from nocapture to stdout also makes it possible to direct that output to some other file/pipe.

Comment thread gitrevise/tui.py Outdated
@rwe

rwe commented Oct 4, 2021

Copy link
Copy Markdown
Contributor Author

The CI error is unrelated to these changes, I believe: it's the GPG changes:

E                   FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.extra'

@krobelus

krobelus commented Oct 4, 2021

Copy link
Copy Markdown
Contributor

Oh well. I've opened #104 which should at least fix the S.gpg-agent.extra bit.
To test that we'd probably need to run a large number of CI jobs, not sure if that's worth it.

@rwe

rwe commented Oct 6, 2021

Copy link
Copy Markdown
Contributor Author

@mystor Not sure if there's a way to re-run the GitHub actions, but I believe this PR is good to go otherwise.

@rwe

rwe commented Jan 10, 2022

Copy link
Copy Markdown
Contributor Author

This PR is still good to go and had no conflicts, but has been rebased as well.

@rwe rwe requested a review from mystor January 10, 2022 18:55
rwe added 4 commits January 10, 2022 13:42
This avoids buffering/consuming output that's always discarded.
The output was previously suppressed/discarded, but that mistake was
made more visible by the explicit "stdout=DEVNULL" argument.
Comment thread gitrevise/odb.py
cwd: Optional[Path] = None,
env: Dict[str, str] = None,
stdin: Optional[bytes] = None,
stdout: _FILE = PIPE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I guess the added consistency is because now input-related parameters come before all output-related ones.

Comment thread gitrevise/odb.py Outdated


T = TypeVar("T") # pylint: disable=invalid-name
_FILE = Union[None, int, IO[Any]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call this File to be consisten with the typing module?

@rwe rwe Jan 26, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, this definition is directly inlined from subprocess.pyi as the type of that Popen argument: https://github.com/python/typeshed/blob/98afaa4c76d4279846f278eb5be8b99c391e6a99/stdlib/subprocess.pyi#L24

It's inlined here because it's not an exported type name, so I wasn't certain it would be importable in all supported versions. Alternatively it could also be done as:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from subprocess import _FILE

My only very minor concern with calling it File is increasing drift from Popen's type.

Preference between:

  • Leave it as is
  • Import it
  • Change name to File

?

@krobelus

Copy link
Copy Markdown
Contributor

LGTM

@krobelus

Copy link
Copy Markdown
Contributor

Ok, then I think leaving it is fine (maybe add a note in the commit message). Importing would be ideal if possible (perhaps even with an alias).
Not sure if the if TYPE_CHECKING check actually makes that easier since the CI runs type checking on all versions.

It's inlined here because it's not an exported type name, so I wasn't certain it would be importable in all supported versions.

I don't know much about Python, I guess it's just about the leading underscore (which by convention means "private")?

@rwe

rwe commented Jan 27, 2022

Copy link
Copy Markdown
Contributor Author

It's inlined here because it's not an exported type name, so I wasn't certain it would be importable in all supported versions.

I don't know much about Python, I guess it's just about the leading underscore (which by convention means "private")?

The leading underscore is the conventional hint, but the practical hiccup was mainly that subprocess.pyi (which the type checker uses) includes the symbol, but subprocess.py itself does not; so it only exists during type-checking and would fail with an ImportError if imported unguarded at runtime.

But I think you're right. Since CI runs on all versions, importing with a if TYPE_CHECKING guard is probably better. That won't ever fail for users, which was my main concern. I'll push something along those lines up and see how it looks. Thank you for the reviews, by the way!

@rwe

rwe commented Jan 27, 2022

Copy link
Copy Markdown
Contributor Author

I believe the CI failure is again unrelated. See #113 for (potential) fix to the race conditions in the current editor-testing code.

@rwe

rwe commented Jan 27, 2022

Copy link
Copy Markdown
Contributor Author

If it’s possible to rerun those tests, please do!

@mystor mystor merged commit 7e3bf8d into mystor:main Feb 5, 2022
@mystor

mystor commented Feb 5, 2022

Copy link
Copy Markdown
Owner

Thanks for the fixes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants