Closed cthoyt closed 6 days ago
I don't think that mypy should support different package managers for this use-case.
You can use any other package manager and install types manually. But, I think that exposing the list of types to install might be a great feature. Something like --list-install-types
Yeah, I think --install-types
was a bit of a mistake. It can effectively make mypy take like twice as long, fails in situations involving cache and packaging is complicated enough that mypy shouldn't get in between users and installation. A --generate-stub-requirements
like sobolevn proposes would be much better. See also https://github.com/python/mypy/issues/10600 and others
Thanks for the feedback. I think sobolevn's proposal is nice.
If there were a --list-install-types
, then you could do something like mypy --list-install-types | xargs uv pip install
.
If you don't think this my specific suggestion is something that could be considered for MyPy, then feel free to close this issue. At least it'll be tracked in #10600!
See my proposal in https://github.com/python/mypy/issues/10600#issuecomment-2481074163
Going to close this! Thanks for the idea :)
Currently, if you want to use mypy with
mypy --install-types
, it requirespip
to be installed.In my case, I am using tox with the tox-uv backend that creates all virtual environments without pip, since
uv pip install
is a drop-in replacement forpip install
. I'm calling mypy in these environments, so I would like to have the possibility to specify the installer used.The main code that would need to be changed is the following:
https://github.com/python/mypy/blob/fa01a0744eded37b61e44c2e00067524a8f9df24/mypy/main.py#L1576
where it might be nice to have the ability to pass in to the enclosing function
install_types()
an additional keyword called "installer" (or synonym) that would enable changing it to something like:This is just a quick, self-contained mockup - there are other patterns that could be used to make this a bit more extensible in case there are other installers desired.
I've got a working demo in https://github.com/python/mypy/compare/master...cthoyt:mypy:uv-installer that I could pull request, but it's not clear to me what is the best way to test this within MyPy's CI