Skip to content

Commit

Permalink
add tests around pylint exit kwargs
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Peveler <[email protected]>
  • Loading branch information
MasterOdin committed Jun 22, 2024
1 parent 3507550 commit e07e337
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pylint_runner/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from argparse import ArgumentParser
import configparser
import os
import re
import sys

import colorama
import pylint
import pylint.lint

from pylint_runner import __version__
from . import __version__
from .utils import get_pylint_kwargs

PYTHON_VERSION = ".".join([str(x) for x in sys.version_info[0:3]])

Expand Down Expand Up @@ -188,14 +188,7 @@ def run(self, output=None, error=None):
# positional arguments
self.args.insert(0, f"--rcfile={self.rcfile}")

pylint_version = pylint.__version__.split('.')[:3]
pylint_version[2] = re.sub(r'[a-z-].*', '', pylint_version[2])
pylint_version = [int(x) for x in pylint_version]

if pylint_version < [2, 5, 1]:
exit_kwarg = {"do_exit": False}
else:
exit_kwarg = {"exit": False}
exit_kwargs = get_pylint_kwargs(pylint.__version__)

run = pylint.lint.Run(self.args + pylint_files, **exit_kwarg)
sys.stdout = savedout
Expand Down
11 changes: 11 additions & 0 deletions pylint_runner/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import re


def get_pylint_kwargs(pylint_version):
""" Get the correct keyword arguments for the pylint runner. """
pylint_version = pylint_version.split('.')[:3]
pylint_version[2] = re.sub(r'[a-z-].*', '', pylint_version[2])
pylint_version = [int(x) for x in pylint_version]
if pylint_version < [2, 5, 1]:
return {"do_exit": False}
return {"exit": False}

0 comments on commit e07e337

Please sign in to comment.