refined-cat-61929
05/28/2024, 2:28 PMmypy
and how pants
is using it. We are using mypy
with protobufs (with mypy-protobuf
, so it generates pyi
files). But pants check
, using mypy
will actually output errors about the pyi
files, which is not something we want.
The issue is that mypy
follows files, and it follows any imports that it can find in MYPYPATH
. Which the generated protobuf files have to be in, otherwise other errors happen. But anything in MYPYPATH
is considered fair game for following and checking.
But if I understand how pants
is working, it is just running mypy
individually on each target, so I think there's no need to follow anything - essentially pants
takes care of making sure our codebase is covered instead. So we can solve the problem of mypy
analyzing pyi
files by passing in --follow-imports=skip
, but that's strongly discouraged by mypy
documentation. However, in this case, with pants
, I think it's the right thing to do. Is this way of thinking reasonable?happy-kitchen-89482
05/28/2024, 9:37 PMhappy-kitchen-89482
05/28/2024, 9:37 PMrefined-cat-61929
05/29/2024, 12:40 AMrefined-cat-61929
05/29/2024, 1:13 AM--follow-imports=skip
works on the command line, it does not work when I add it to my mypy args in pants.toml
. But I'm not sure why the mypy runner is running over the pyi
file in the first place.refined-cat-61929
05/29/2024, 1:28 AMpython_sources
build rule include "*.pyi" as a glob. When it is setting up its runtime directory, the protobuf generated pyi files match the glob, even though they really aren't part of the source.happy-kitchen-89482
05/29/2024, 1:40 PMhappy-kitchen-89482
05/29/2024, 1:40 PMhappy-kitchen-89482
05/29/2024, 1:41 PMhappy-kitchen-89482
05/29/2024, 1:41 PMrefined-cat-61929
05/29/2024, 6:12 PMmypy
for processing? I was expecting it to be controlled by the glob, but as you say, maybe by the time we're in the sandbox, the glob has already done its work and is not useful anymore.
There may not be a difference between the command-line vs not. I'm testing the command-line of a file that uses the protobufs that have the pyi
files, and my command-line run for that file is successful. However, my success means nothing if Pants is actually also calling mypy
on the pyi
files (or doing the equivalent via the mypy
daemon).happy-kitchen-89482
05/29/2024, 6:30 PMglobs
in BUILD files just group files together for the purpose of applying target metadata to them (and if you add an explicit dependency on the target then that's as if you added one for each of the files in the target)happy-kitchen-89482
05/29/2024, 6:30 PMhappy-kitchen-89482
05/29/2024, 6:31 PM--keep-sandboxes=always
, which will log the locations of each sandboxhappy-kitchen-89482
05/29/2024, 6:31 PMhappy-kitchen-89482
05/29/2024, 6:31 PMhappy-kitchen-89482
05/29/2024, 6:31 PMhappy-kitchen-89482
05/29/2024, 6:33 PMpants dependencies --transitive <command line specs>
)
B) Any generated codehappy-kitchen-89482
05/29/2024, 6:33 PMrefined-cat-61929
05/29/2024, 6:57 PMrefined-cat-61929
05/29/2024, 7:43 PMrefined-cat-61929
05/30/2024, 4:24 AMrefined-cat-61929
05/30/2024, 4:37 AMmypy
and mypy-protobuf
together. I believe if you do, you'll be getting errors in pyi
files, without any easy way to configure mypy
to ignore those files.happy-kitchen-89482
05/30/2024, 5:00 AMhappy-kitchen-89482
05/30/2024, 5:01 AMhappy-kitchen-89482
05/30/2024, 5:02 AMhappy-kitchen-89482
05/30/2024, 5:03 AMhappy-kitchen-89482
05/30/2024, 5:44 AMrefined-cat-61929
05/30/2024, 3:26 PMhappy-kitchen-89482
05/30/2024, 11:09 PMhappy-kitchen-89482
05/30/2024, 11:09 PMrefined-cat-61929
05/31/2024, 4:33 AMpyi
file mypy-protobuf
generates.happy-kitchen-89482
05/31/2024, 4:35 PM@__files.txt
. I have a feeling that we put those generated files in that list, and we shouldn't.happy-kitchen-89482
05/31/2024, 4:36 PMrefined-cat-61929
06/04/2024, 5:44 PMrefined-cat-61929
06/04/2024, 5:45 PMhappy-kitchen-89482
06/04/2024, 6:43 PMhappy-kitchen-89482
06/04/2024, 6:43 PMhappy-kitchen-89482
06/04/2024, 6:43 PM