Skip to content
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

Reading mypy.ini or setup.cfg in parent directories. #3377

Closed
co-dh opened this issue May 17, 2017 · 4 comments
Closed

Reading mypy.ini or setup.cfg in parent directories. #3377

co-dh opened this issue May 17, 2017 · 4 comments

Comments

@co-dh
Copy link

co-dh commented May 17, 2017

I have a folder structure like this:

foo\
  src\a.py
  test\test_a.py

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.

Regards.

@miedzinski
Copy link
Contributor

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
Copy link
Member

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
Copy link

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
Copy link

mihaic commented Jun 2, 2021

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.

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

No branches or pull requests

5 participants