-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Default src.root
to ['.', '<project_name>']
if the directory exists
#18141
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
Conversation
069d2bb
to
7701d68
Compare
and mypy primer hangs here too :( I wonder if it is just because of the too large diff. Any suggestions on how I could try this out? |
|
6cfa747
to
74d5f25
Compare
There are no other changes to mypy primer, so maybe it's not worth changing the default just for one project. I'd be interested to hear from people with more knowledge of the Python ecosystem to hear how common this project structure is. |
I think we should fix this for this specific mypy primer project for now. We can consider changing our heuristics if this comes up more frequently. |
Summary
I noticed in #18137 that we fail to resolve all imports for some ecosystem repositories because they don't use the "traditional" src or flat layouts. Instead, they use a
src
layout but they use the project name instead ofsrc
for the "src folder name".An example is
psycopg
where all source files are inpsycopg/psycopg/_adapters_map.py:279:14
This PR extends our heuristics for
src.root
to recognize if a project has a<project>/<project>
folder (and nosrc
folder) and, if so, includes it in thesrc.root
.The motivation for this change is to support more projects with zero configuration.
I don't have a good sense of how common this project layout is, but it seems worth supporting, given that multiple ecosystem projects use it. This also makes our mypy primer results significantely more useful :)
Test plan
See mypy primer results, added unit tests.