mypy with `--install-types` as an arg fails to install types because process is interactive
See original GitHub issueI know this is not a problem with pre-commit per se. But as of mypy==0.902
warnings that stubs were not installed stared popping up while running pre-commit (see example)
dbt_sugar/core/ui/cli_ui.py:6: error: Library stubs not installed for "click" (or incompatible with Python 3.7)
dbt_sugar/core/ui/cli_ui.py:6: note: Hint: "python3 -m pip install types-click"
dbt_sugar/core/ui/cli_ui.py:8: error: Library stubs not installed for "yaml" (or incompatible with Python 3.7)
dbt_sugar/core/clients/yaml_helpers.py:7: error: Library stubs not installed for "yaml" (or incompatible with Python 3.7)
dbt_sugar/core/clients/yaml_helpers.py:7: note: Hint: "python3 -m pip install types-PyYAML"
dbt_sugar/core/clients/yaml_helpers.py:7: note: (or run "mypy --install-types" to install all missing stub packages)
dbt_sugar/core/clients/yaml_helpers.py:7: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
I was thinking that passing the --install-types
as one of the arguments on my pre-commit config would do the trick but I get a failure which I think is due to the fact that --install-types
requires a yes/no user input (as discussed here: https://github.com/python/mypy/issues/10600#issuecomment-857351152). Here’s the error message:
Installing missing stub packages:
/Users/bastienboutonnet/.cache/pre-commit/repochpm25o9/py_env-python3.8/bin/python -m pip install types-PyYAML types-click
Install? [yN] Traceback (most recent call last):
File "/Users/bastienboutonnet/.cache/pre-commit/repochpm25o9/py_env-python3.8/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/Users/bastienboutonnet/.cache/pre-commit/repochpm25o9/py_env-python3.8/lib/python3.8/site-packages/mypy/__main__.py", line 11, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 133, in main
File "mypy/main.py", line 1093, in install_types
EOFError: EOF when reading a line
(also happens when running pre-commit.ci on my public repo (https://github.com/bitpicky/dbt-sugar/pull/290)
Looks like there is a new flag which will be shipped as part of 910 but I was wondering if in the meantime there was a way to run pre-commit with install-types in a way to fake the yes answer? a bit like the comment above does with pipes.
If not I’ll turn off that check from mypy until they fix it but I thought maybe there’s a way?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
the problem is
types-all
is a hack / workaround and would further differ from vanilla mypythey’re all public, feel free to answer your own question