Arc lint is unable to parse pylint version number for pylint 2.0.0


Observed Behavior:
Running arc lint with pylint as the selected linter, with pylint v 2.0.0 installed, results in an Exception claiming the installed version of pylint is too low (minimum 1.0.0), quoting a blank string as the installed version number.

Expected Behavior:
arc lint runs successfully with pylint 2.0.0

Phabricator Version:

> arc --version
arcanist 875d018360374cb4b1287309782fcb9a75d4bcbf (9 Jul 2018)
libphutil 4206849bb05b60f536a1c78e33adee68dac67aa9 (7 Jun 2018)

Reproduction Steps:
Install pylint v2.0.0 or above. Set pylint as the arc linter in .arclint:.

  "linters": {
    "pylint": {
        "type": "pylint"

Run arc lint:

ArcanistPyLintLinter is not compatible with the installed version of pylint. Minimum version: 1.0.0; installed version: .
(Run with `--trace` for a full exception trace.)

The issue appears to be in src/lint/linter/ArcanistPyLintLinter.php, function getVersion(), which matches the version number with the following regex, which requires a comma at the end:

^pylint (?P<version>\d+\.\d+\.\d+),

With pylint v1.9.2, pylint --version outputs the following, including comma:

pylint 1.9.2,
astroid 1.6.5

With pylint v2.0.0, pylint --version no longer includes a comma:

pylint 2.0.0
astroid 2.0.1

I don’t know if the comma is necessary to correctly parse the output of some pylint versions.


We’ve run into the same problem here, and your diagnosis looks correct; this change was enough to make things work again:

diff --git a/src/lint/linter/ArcanistPyLintLinter.php b/src/lint/linter/ArcanistPyLintLinter.php
index 44793a50..020876e4 100644
--- a/src/lint/linter/ArcanistPyLintLinter.php
+++ b/src/lint/linter/ArcanistPyLintLinter.php
@@ -38,7 +38,7 @@ final class ArcanistPyLintLinter extends ArcanistExternalLinter {
     list($stdout) = execx('%C --version', $this->getExecutableCommand());

     $matches = array();
-    $regex = '/^pylint (?P<version>\d+\.\d+\.\d+),/';
+    $regex = '/^pylint (?P<version>\d+\.\d+\.\d+),?/';
     if (preg_match($regex, $stdout, $matches)) {
       return $matches['version'];
     } else {