Put the .mypy_cache directory near the project configuration file instead of at the current working directory
Feature
If there is a project configuration file (pyproject.toml, mypy.ini etc), make the default .mypy_cache directory be near the configuration file instead of at the current working directory.
Pitch
Currently, the .mypy_cache directory is created by default in the current working directory. I was very surprised to find this. It means that I probably have many .mypy_cache directories hanging around in unexpected places, possibly in unrelated projects. It also means that I had to wait for the cache to be rebuilt when there was a perfectly good cache sitting elsewhere.
I think that when there is a notion of a project, the .mypy_cache directory should be at the root of the project. So, when mypy uses a project configuration file, I think that since there is an obvious project directory, the .mypy_cache directory should be there.
I think this is a duplicate of #7967. The current solution is to add $MYPY_CONFIG_FILE_DIR in the configuration file:
[tool.mypy]
cache_dir = "$MYPY_CONFIG_FILE_DIR/.mypy_cache"
Not quite a dupe, imo, but definitely related!