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
{{ message }}
Repository navigation
Reading mypy.ini or setup.cfg in parent directories. #3377
I'm also using flycheck/mypy to check my files in emacs, however, it only read mypy.ini from current folder,
which is the file that I'm visiting.
I'm wondering if we can let mypy read config file from current folder, parent folder, grandparent folder etc until it find one. This is the same way of git looking for .gitignore, and nodejs looking for node_modules.
If you think it's a good idea, I might be able to write the code and make a PR.
I'm not sure whether mypy would work from those subdirectories because of how imports are resolved. Based on my experience it's better to typecheck the project as a whole, with current directory set to top project directory.
I considered this when I first implemented the config file, but I don't think that is a good idea. Most projects don't have a mypy.ini or setup.cfg file and I don't want some file by that name in e.g. my home directory to affect mypy's behavior in all subdirectories. It's easy to forget that that file exists and easy to be confused by some of the many flags that could be present in such a file.
This is frustrating me currently. One use case for this is using mypy in an IDE to type check while coding. In order to get it working, you'd have to do something like symlink your mypy.ini files to all directories.
I don't understand your concern about a mypy.ini in your home directory. It seems to me that this is essentially the same as the one in your ~/.config/ dir. They're both hidden and affect all mypy invocations.
Reacted by henribru, Nick Sweeting, Vikash, Clément Pit-Claudel, LiterallyUniqueLogin, Ayush Ranjan, Manoel V. Machado, Duncan Holm, Tuukka Mustonen, Mihai Capotă and 1 more
Please consider revisiting this decision in light of the Python Packaging Authority switching to the src directory structure in the Python Packaging User Guide. I frequently edit files while the current directory is src and Mypy does not use the configuration file next to src.
Reacted by pauladams12345, Olzhas Arystanov, tombohub and Levi Cameron
Activity
miedzinski commentedon May 17, 2017
I'm not sure whether mypy would work from those subdirectories because of how imports are resolved. Based on my experience it's better to typecheck the project as a whole, with current directory set to top project directory.
gvanrossum commentedon May 18, 2017
I considered this when I first implemented the config file, but I don't think that is a good idea. Most projects don't have a mypy.ini or setup.cfg file and I don't want some file by that name in e.g. my home directory to affect mypy's behavior in all subdirectories. It's easy to forget that that file exists and easy to be confused by some of the many flags that could be present in such a file.
onlyanegg commentedon May 23, 2019
This is frustrating me currently. One use case for this is using mypy in an IDE to type check while coding. In order to get it working, you'd have to do something like symlink your mypy.ini files to all directories.
I don't understand your concern about a mypy.ini in your home directory. It seems to me that this is essentially the same as the one in your
~/.config/dir. They're both hidden and affect all mypy invocations.mihaic commentedon Jun 2, 2021
Please consider revisiting this decision in light of the Python Packaging Authority switching to the
srcdirectory structure in the Python Packaging User Guide. I frequently edit files while the current directory issrcand Mypy does not use the configuration file next tosrc.