I migrated some code to a Pants project, and it ha...
# general
c
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
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
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
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
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
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
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
I’m surprised/impressed this works even outside of Pants TBH! Shadowing names like that seems like a recipe for disaster… 🙂
1