You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if you want to use mypy with mypy --install-types, it requires pip 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 for pip 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:
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:
ifinstaller=="pip":
assertoptions.python_executable, "Python executable required to install types with pip"cmd= [options.python_executable, "-m", "pip", "install"] +packageselifinstaller=="uv":
importshutil# there are two possibilities here, since there might be a globally# installed uv that is not managed by the current python environmentifshutil.which("uv"):
cmd= ["uv", "pip", "install"] +packageselse:
assertoptions.python_executable, "Python executable required to install types with uv"cmd= [options.python_executable, "-m", "uv", "pip", "install"] +packageselse:
raiseValueError(f"Unknown installer: {installer}")
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 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
The text was updated successfully, but these errors were encountered:
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:
mypy/mypy/main.py
Line 1576 in fa01a07
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 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
The text was updated successfully, but these errors were encountered: