mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Better documentation around using different python versions for different modules

Open neelmraman opened this issue 1 year ago • 5 comments

Documentation

As far as I can tell from the docs/google searches/looking through github issues, there isn't guidance on the standard or simplest ways to run mypy in a monorepo of sorts where different directories are on different python versions. I was hoping I could use the python_version config option, but it seems like that can only be set on a global level.

I guess one workaround would be replacing calls like mypy . with a series of calls running over specific directories with their specific python versions, but I was wondering if there is a less cumbersome approach.

neelmraman avatar Feb 23 '24 20:02 neelmraman

Hi! I’d like to contribute to this issue.

Before I get started, I wanted to check something with you: should I add the documentation directly in the config_file.rst file, or would you prefer that I create a new documentation file instead?

Thanks in advance for your guidance!

lamia-bel avatar Dec 01 '25 08:12 lamia-bel

Hi,

I tried to build the documentation locally to test my changes, but I am working on Windows and ran into platform-specific issues (missing librt, which seems to be a Linux-only dependency used by the docs build system).

Because of this, I could not fully compile the documentation locally. The RST formatting was checked, and the changes are documentation-only.

Could you please confirm if this is acceptable, and if the documentation can be validated in your Linux/CI environment?

Thank you!

lamia-bel avatar Dec 08 '25 08:12 lamia-bel

Hi,

I added a note about using multiple Python versions in a monorepo and suggested three workarounds (multiple runs, separate config files, external tools). I’m on Windows and cannot test them due to ModuleNotFoundError: librt. Could you test them on the intended environment?

Thank you,

lamia-bel avatar Dec 08 '25 09:12 lamia-bel

I’m on Windows and cannot test them due to ModuleNotFoundError: librt. Could you test them on the intended environment?

Try pip install . again? Mypy's deps changed, so it's possible your venv isn't up to date.

A5rocks avatar Dec 08 '25 22:12 A5rocks

@lamia-bel I use Windows 10 and I run my projects in a venv using uv run runtests.py. Today I started getting cannot import name 'Buffer' from 'librt.internal' errors when trying to run the self-test. For whatever reason, this didn't resolve until I merged master into my branch. So, I recommend merging master into your branch or rebasing your branch onto master if pip install . and pip install -r test-requirements.txt aren't working for you.

wyattscarpenter avatar Dec 11 '25 06:12 wyattscarpenter

@A5rocks

Hi,

I tested the workarounds on Windows and generated config_file.html. Everything worked fine, and no errors appeared in the documentation. Could you please check if this is okay for my work?

Thank you!

lamia-bel avatar Dec 21 '25 08:12 lamia-bel

@wyattscarpenter Thanks, this was really helpful!

lamia-bel avatar Dec 21 '25 08:12 lamia-bel