https://pantsbuild.org/ logo
#general
Title
# general
c

cold-vr-15232

12/01/2022, 7:47 PM
I migrated some code to a Pants project, and it has some weird structure. The issue is that running lint shows some messages that don't have source references, and I don't have direct references in the code to those modules. Does anyone know? These are reported by pylint, but I suppose that somehow pylint gets to run on something that is not in the source code?
*************
<?>:16:4: W0622: Redefining built-in 'exit' (redefined-builtin)
*************
<?>:4:4: W0611: Unused import _pytest.mark (unused-import)
*************
<?>:5:4: W0611: Unused import _pytest.recwarn (unused-import)
🤯 2
h

hundreds-father-404

12/01/2022, 7:59 PM
Huh....I would suggest trying to narrow down the problem. For example, if you're running
./pants lint ::
, try
./pants lint dir1::
(tip to use
./pants lint --only=pylint
to skip other linters/formatters)
c

cold-vr-15232

12/01/2022, 8:09 PM
Great suggestion, thanks. I found the issue, some idiot named a local module pytest.py..... Unfortunately, I think that name is needed, but if I'm lucky it might work with a separate lockfile that doesn't include pytest.
h

hundreds-father-404

12/01/2022, 8:10 PM
oh hm, where is the file located relative to your "source roots"? Because normally that file would be something like
my_project.utils.pytest
, rather than the top-level symbol module
pytest
c

cold-vr-15232

12/01/2022, 8:12 PM
Like I said, the project structure is a mess. There are some folders that are used for plugins, and these are special. But yes, I should look at fiddling with the source roots too.
👍 1
h

hundreds-father-404

12/01/2022, 8:13 PM
Cool, I suspect your best options are either a) rename the file to something like
my_pytest.py
or b) nest it under a directory like
utils
so that it's
utils.pytest
rather than
pytest
(source roots)
c

cold-vr-15232

12/01/2022, 8:16 PM
I think the name is used with reflection, to locate it among all plugin modules. It's a bad system, and I start to doubt I can mangle it to work with Pants. Not with a big refactoring. The folder containing pytest.py is not even listed as a source root.
h

happy-kitchen-89482

12/02/2022, 1:07 AM
I’m surprised/impressed this works even outside of Pants TBH! Shadowing names like that seems like a recipe for disaster… 🙂
1
3 Views