brash-student-40401
11/30/2022, 7:45 PMsrc
├── common
│ ├── auth
| ├── BUILD
| ├── auth1.py
| ├── auth2.py
│ └── mypy-stubs
| ├── BUILD
| ├── auth1.pyi
│ └── auth2.pyi
├── services
│ ├── app
| ├── BUILD
│ └── app.py
I want to run type-checking on app
, which imports `auth1`/`auth2`. When I list dependencies for auth
, I see the `pyi`s, but I don't see them in dependencies for app
. I have tried explicitly listing them app's BUILD
, and they will be listed as dependencies when I do, but the type check still fails with error: Cannot find implementation or library stub for module named "common.auth.auth1"
(same error for auth2
). I feel like I've gotten this to work in the past - what am I missing here?brash-student-40401
11/30/2022, 7:48 PMpython_sources()
defined. The docs say
You can use .pyi files for both first-party and third-party code. Include the .pyi files in the sources field for python_source / python_sources and python_test / python_tests targets. MyPy will use these stubs rather than looking at the implementation.
but I cannot find a place to put the `pyi`s where I do not get the missing stub error.wide-midnight-78598
11/30/2022, 7:50 PMwide-midnight-78598
11/30/2022, 7:50 PMbrash-student-40401
11/30/2022, 7:54 PMauth
and app
directories, and an __init__.pyi
in the mypy-stubs
directory.
2. I'm using mypy through the ./pants check
goal. My understanding is that it will use standard dependency inference to find the stubs, but clearly that is not the case. How else can I get it to find them?happy-kitchen-89482
11/30/2022, 8:25 PMbrash-student-40401
11/30/2022, 8:30 PMsrc/common/auth/mypy-stubs/
as a root, but still got the error.happy-kitchen-89482
11/30/2022, 8:35 PMauth
and services
the top-level packages? If so then src/
should be a source root (and it may already be one, I just want to verify). You can see your source roots with ./pants roots
brash-student-40401
11/30/2022, 8:45 PMsrc/
is a source root