https://pantsbuild.org/ logo
r

rhythmic-glass-66959

10/03/2022, 8:09 PM
Hi there, I'm trying to use the
flake8-requirements
plugin. Since my
requirements.txt
is not in the project's root directory, I need to pass the
--requirements-file
option pointing to the requirements in
3rdparty/python
. So I added this to `[flake8].args`:
Copy code
[flake8]
args = [
   ...,
    "--requirements-file=3rdparty/python/requirements.txt",
]
However, the plugin doesn't seem to be able to read the text file. I suspect an issue with the sandbox. Any ideas?
b

bitter-ability-32190

10/03/2022, 8:14 PM
I think you might find that Pants can/should just provide the same functionality for you. ā€¢
Package is not listed as a requirement.
-> https://www.pantsbuild.org/docs/reference-python-infer#unowned_dependency_behavior set to
error
ā€¢
Package is required but not used.
right now it's a manual step but I'd love to write a plugin for this. Today you can run
./pants dependees <requirement address>
and pipe through
wc -l
. You should see 1 dependee (the target generator) for dependencies which aren't used
r

rhythmic-glass-66959

10/03/2022, 8:22 PM
Thx @bitter-ability-32190. In the meantime, is there anything I can do to make the plugin works? In the sandbox the requirements files are not present...
b

bitter-ability-32190

10/03/2022, 8:26 PM
Because we batch your inputs I don't think you'll find much success even if you did get it working. The
flake8
run will only have a subset of your code, so I imagine you'd get
Package is required but not used.
in a fair number of runs šŸ˜ž
Essentially we run
flake8
on many subset of overall repo to make subsequent runs relatively speedy
r

rhythmic-glass-66959

10/03/2022, 8:30 PM
I see. I'll ditch
flake8-requirements
for now, and wait for your plugin šŸ˜‰. Thanks for your quick response.
b

bitter-ability-32190

10/03/2022, 8:30 PM
Defintely look into enabling the linked setting
r

rhythmic-glass-66959

10/03/2022, 8:31 PM
Will do!
Works as expected :
UnownedDependencyError: Pants cannot infer owners for the following imports in the target ...
šŸ™Œ 2
b

bitter-ability-32190

10/03/2022, 9:06 PM
That's exactly why I wrote this feature šŸ˜ø
FYI @hundreds-father-404 should we have a snippet in the docs regarding this plugin? I can try and whip up the plugin
h

hundreds-father-404

10/03/2022, 9:35 PM
hould we have a snippet in the docs regarding this plugin?
saying?
b

bitter-ability-32190

10/03/2022, 9:41 PM
Basically my two points above. "it won't work, but that's ok because pants can do the same thing ..."
h

hundreds-father-404

10/03/2022, 9:44 PM