numerous-city-13071
11/17/2023, 2:39 PMpants.base.exceptions.BackendConfigurationError: Failed to load the gp_checks.register backend: ModuleNotFoundError("No module named 'my_checker.register'")
After adding my new rule's module to backend_packages
inside pants.toml
.
I went through the documentation on how to define a new pylint checker and have add a register
function:
def register(linter: "PyLinter") -> None:
"""
This required method auto registers the checker during initialization.
:param linter: The linter to register the checker to.
"""
linter.register_checker(MyChecker(linter))
My MyChecker
roughly looks like:
from pylint import checkers
class MyChecker(checkers.BaseChecker):
...
Now, I've seen @rule
too, but I am unsure how to proceed -> what should I put in the my_checker/register.py
such that my new checker can be run?curved-television-6568
11/17/2023, 2:47 PMnumerous-city-13071
11/17/2023, 2:54 PMMyChecker
-> Rule
?curved-television-6568
11/17/2023, 2:56 PMcurved-television-6568
11/17/2023, 2:59 PMcurved-television-6568
11/17/2023, 2:59 PMcurved-television-6568
11/17/2023, 3:00 PMcurved-television-6568
11/17/2023, 3:02 PMnumerous-city-13071
11/17/2023, 3:09 PMnumerous-city-13071
11/17/2023, 3:10 PMnumerous-city-13071
11/17/2023, 3:10 PMcurved-television-6568
11/17/2023, 3:12 PMnumerous-city-13071
11/17/2023, 3:12 PMnumerous-city-13071
11/20/2023, 9:24 AM./pants lint app::
[...]
stderr:
A distribution for babel could not be resolved for /home/admin/.pyenv/versions/3.10.5/bin/python3.10.
09:20:53.41 [INFO] Canceled: Building 2 requirements for pylint.pex from the tools/python/pylint/pylint-resolve.lock resolve: astroid, pylint<3,>=2.13.0
I am unsure how to continue now...
I added this to my `pants.toml`:
[pylint]
args = [
"--disable=all",
"--enable=gp-check-simple-dtos",
]
config = "pyproject.toml"
lockfile = "tools/python/pylint/pylint-resolve.lock"
install_from_resolve = "pylint"
source_plugins = [
"pylint_plugins:pylint-plugins-sources",
]
version = "pylint>=2.13.0,<2.15"
[source]
root_patterns = [
...
"/pylint_plugins",
]
[python]
...
enable_resolves = true
[python.resolves.add]
...
pylint = "tools/python/pylint/pylint-resolve.lock"
backend_packages = [
...
"pants.backend.python.lint.pylint",
]
And `pyproject.toml`:
[tool.pylint]
load-plugins = [
"check_simple_dtos",
]
This is how my pylint_plugins/BUILD
looks like:
python_requirement(
requirements=["astroid", "pylint>=2.13.0,<3"],
resolve="pylint",
)
python_sources(
name="pylint-plugins-sources",
sources=["**/*.py", "!**/test_*.py"],
resolve="pylint",
)
I ran pants generate-lockfiles --resolve=pylint
to create the lock file in tools/python/pylint/pylint-resolve.lock
.
Any help would be very welcome! Also, as a side note, I got some deprecated warnings about using version
and lockfile
and that I should use install_from_resolve
instead. But, if I leave out lockfile
then it complains that no lockfile
is found when running the generate-lockfiles --resolve=pylint
command.