Skip to content

Commit

Permalink
fix: handle stdin not being tty in interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanthkoushik committed May 23, 2024
1 parent 6604351 commit 4a494d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/pyseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,4 +1760,10 @@ def main():


if __name__ == "__main__":
if len(sys.argv) <= 1 and not sys.stdin.isatty():
try:
sys.stdin = open("/dev/tty", mode="r") # noqa: SIM115
except OSError:
print("could not open tty for interactive config", file=sys.stderr)
sys.exit(1)
main()
3 changes: 2 additions & 1 deletion tests/test_pyseed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import os
import subprocess
import sys
import textwrap
from argparse import ArgumentError, ArgumentParser
Expand Down Expand Up @@ -62,7 +63,7 @@ def inside_temp_poetry_dir():
class TestGetGitUser(TestCase):
def test_get_git_user_returns_configured_value(self):
with inside_temp_dir():
pyseed.vrun(["git", "init"])
subprocess.run(["git", "init", "-q"], check=True)
with (Path(".git") / "config").open("w") as f:
print(
textwrap.dedent("""\
Expand Down

0 comments on commit 4a494d6

Please sign in to comment.