pre-commit install silently fails when running in git-bash
See original GitHub issuedescribe your issue
I am actually doing dev work on pyscaffold, which uses pre-commit. Problems there led me to track the problem back to pre-commit.
Running on Windows 10 in git-bash the command precommit install
produces no output, but has a return code of 1.
I tracked the problem to sys.stderr being used without checking that it is not None It happens at main.py line 335 - args = parser.parse_args(argv)
pre-commit --version
2.17.0
.pre-commit-config.yaml
just an empty file
~/.cache/pre-commit/pre-commit.log (if present)
I tracked it down and found the exception and printed it for you.
Traceback (most recent call last): File “C:\Users\julie\juliehome.venvs\pyscaffold\lib\site-packages\pre_commit\main.py”, line 342, in main args = parser.parse_args(argv) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 1825, in parse_args args, argv = self.parse_known_args(args, namespace) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 1858, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 2070, in _parse_known_args stop_index = consume_positionals(start_index) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 2026, in consume_positionals take_action(action, args) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 1935, in take_action action(self, namespace, argument_values, option_string) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 1213, in call subnamespace, arg_strings = parser.parse_known_args(arg_strings, None) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 1858, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 2092, in _parse_known_args self._get_value(action, action.default)) File “C:\Users\julie\AppData\Local\Programs\Python\Python310\lib\argparse.py”, line 2483, in _get_value result = type_func(arg_string) File “C:\Users\julie\juliehome.venvs\pyscaffold\lib\site-packages\pre_commit\color.py”, line 94, in use_color sys.stderr.isatty() and AttributeError: ‘NoneType’ object has no attribute ‘isatty’
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
please do not, stderr should never be
None
. this is not “defensive programming” this is complexity against an impossible situationI’ve done much more research on this issue and in my case there is both the problem with pip22 and a problem with git-bash and others using mintty.
thanks for your help