[virt-tools-list] [virt-manager] [PATCH 1/5] pylint: Use pylint.lint module

Radostin Stoyanov rstoyanov1 at gmail.com
Fri Mar 2 08:01:21 UTC 2018


The `pylint-3` executable is provided by the python3-pylint rpm
package on Fedora.
For Debian the equivalent is `pylint3`.
On Arch Linux the default version of Python is 3.

Pylint lints for the version of Python it is running. Instead of
spawning an executable, import the `pylint.lint` module and call
`Run()`.

Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 setup.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/setup.py b/setup.py
index cd0278ba..33a1b478 100755
--- a/setup.py
+++ b/setup.py
@@ -581,6 +581,8 @@ class CheckPylint(distutils.core.Command):
             self.jobs = int(self.jobs)
 
     def run(self):
+        import pylint.lint
+
         files = ["setup.py", "virt-install", "virt-clone",
                  "virt-convert", "virt-xml", "virt-manager",
                  "virtcli", "virtinst", "virtconv", "virtManager",
@@ -597,15 +599,14 @@ class CheckPylint(distutils.core.Command):
         os.system(cmd)
 
         print("running pylint")
-        cmd = "pylint-3 "
+        pylint_opts = [
+            "--rcfile", "tests/pylint.cfg",
+            "--output-format=%s" % output_format,
+        ] + ["--ignore"] + [os.path.basename(p) for p in exclude]
         if self.jobs:
-            cmd += "--jobs=%d " % self.jobs
-        cmd += "--rcfile tests/pylint.cfg "
-        cmd += "--output-format=%s " % output_format
-        cmd += "--ignore %s " % ",".join(
-            [os.path.basename(p) for p in exclude])
-        cmd += " ".join(files)
-        os.system(cmd)
+            pylint_opts += ["--jobs=%d" % self.jobs]
+
+        pylint.lint.Run(files + pylint_opts)
 
 
 class VMMDistribution(distutils.dist.Distribution):
-- 
2.14.3




More information about the virt-tools-list mailing list