Skip to content

difference in stdin handling, prek hangs forever #1154

@spaceone

Description

@spaceone

Summary

I have a pre-commit hook which is a wrapper around ruff.
It basically calls:

cmd = ['ruff', 'check', '--fix', '--extend-ignore', 'ERA,RUF005,UP008,UP031,UP032,E501,UP009,PGH004,FURB156,CPY001,F821', '--stdin-filename', 'blah', '--', '/tmp/tmp4avodvqg']
process = subprocess.Popen(cmd, stdin=None, stderr=subprocess.STDOUT)
process.communicate()

The ruff subprocess now waits for stdin, which will never get any.

sys.stdin.isatty() returns True with prek, and False with pre-commit.

I can workaround it by passing stdin=open('/dev/null') to the subprocess.

Platform

Linux 6.5.0-0.deb12.1-amd64 x86_64 GNU/Linux

Version

0.2.17

.pre-commit-config.yaml

No response

Log file

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions