Skip to content

Config file at ~/.mypy.ini is not used #18977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jolaf opened this issue Apr 27, 2025 · 1 comment
Closed

Config file at ~/.mypy.ini is not used #18977

jolaf opened this issue Apr 27, 2025 · 1 comment
Labels
bug mypy got something wrong

Comments

@jolaf
Copy link
Contributor

jolaf commented Apr 27, 2025

Bug Report

I have my mypy configuration file at ~/.mypy.ini.

In that config file I have the following option:

[mypy]
cache_dir=/tmp/mypy_cache

However when I run mypy from some working directory, .mypy_cache directory gets created in that directory, which means my config file is not used.

However, if I specify path to that config file directly, it's used correctly:

$ mypy -v --config-file ~/.mypy.ini SomeFile.py

LOG:  Mypy Version:           1.15.0
LOG:  Config File:            /home/user/.mypy.ini
LOG:  Configured Executable:  /usr/bin/python3
LOG:  Current Executable:     /usr/bin/python3
LOG:  Cache Dir:              /tmp/mypy_cache
...

Unfortunately, mypy doesn't print the location of the config file it uses, or the locations where it tries to find a config file, so no more details on the problem is available.

Expected Behavior

As stated in the documentation: https://mypy.readthedocs.io/en/stable/config_file.html
~/.mypy.ini should be used if --config-file is not specified and other preferred config file locations do not exist, which it true in my case.

So I would expect the exact same behavior if --config-file ~/.mypy.ini is specified and if --config-file is not specified at all.

Actual Behavior

$ mypy -v SomeFile.py

LOG:  Mypy Version:           1.15.0
LOG:  Config File:            Default
LOG:  Configured Executable:  /usr/bin/python3
LOG:  Current Executable:     /usr/bin/python3
LOG:  Cache Dir:              .mypy_cache
...

Note Config File: Default and Cache Dir: .mypy_cache.

And indeed, ./.mypy_cache folder is created.

Your Environment

$ mypy --version
mypy 1.15.0 (compiled: yes)

$ python --version
Python 3.12.3
@jolaf jolaf added the bug mypy got something wrong label Apr 27, 2025
@sterliakov
Copy link
Collaborator

Yes, user-level config file discovery was broken in 1.15.0, fixed in #18656 approx. a week after release. I confirmed that global config doesn't work in 1.15.0 and works on current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants