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

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

Merged
merged 5 commits into from
Feb 5, 2022

Conversation

rwe
Copy link
Contributor

@rwe rwe commented Sep 29, 2021

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.

gitrevise/tui.py Outdated Show resolved Hide resolved
@rwe
Copy link
Contributor Author

rwe commented Oct 4, 2021

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
Copy link
Contributor

krobelus commented Oct 4, 2021

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
Copy link
Contributor Author

rwe commented Oct 6, 2021

@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
Copy link
Contributor Author

rwe commented Jan 10, 2022

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.
stdin: Optional[bytes] = None,
stdout: _FILE = PIPE,
Copy link
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.

gitrevise/odb.py Outdated
@@ -43,6 +45,7 @@ def __init__(self, stderr: str) -> None:


T = TypeVar("T") # pylint: disable=invalid-name
_FILE = Union[None, int, IO[Any]]
Copy link
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?

Copy link
Contributor Author

@rwe rwe Jan 26, 2022

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
Contributor

LGTM

@krobelus
Copy link
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
Copy link
Contributor Author

rwe commented Jan 27, 2022

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
Copy link
Contributor Author

rwe commented Jan 27, 2022

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

@rwe
Copy link
Contributor Author

rwe commented Jan 27, 2022

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

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

mystor commented Feb 5, 2022

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