diff --git a/NEWS.rst b/NEWS.rst index de54bc074c53e6ac5e6da1ea27873a513bafa81d_TkVXUy5yc3Q=..587f1c601633e0af541a7dfe3c837053f0ac25a7_TkVXUy5yc3Q= 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -5,7 +5,7 @@ 18.1.0 ------ -Use pylint colorized output. +Add pylint output format option and default to a colorized output. 18.0.1 ------ diff --git a/odoo_scripts/docker_pylint.py b/odoo_scripts/docker_pylint.py index de54bc074c53e6ac5e6da1ea27873a513bafa81d_b2Rvb19zY3JpcHRzL2RvY2tlcl9weWxpbnQucHk=..587f1c601633e0af541a7dfe3c837053f0ac25a7_b2Rvb19zY3JpcHRzL2RvY2tlcl9weWxpbnQucHk= 100644 --- a/odoo_scripts/docker_pylint.py +++ b/odoo_scripts/docker_pylint.py @@ -52,8 +52,15 @@ default=[], nargs="+", ) + parser.add_argument( + "--pylint-output-format", + help="Run pylint with the --output-format provided (for example colorized or " + "parseable)", + dest="pylint_output_format", + default="colorized", + ) def apply_pylint(namespace: argparse.Namespace) -> int: """Run pylint if the option was set.""" if _PYLINT_DEST in namespace and getattr(namespace, _PYLINT_DEST): @@ -55,9 +62,13 @@ def apply_pylint(namespace: argparse.Namespace) -> int: """Run pylint if the option was set.""" if _PYLINT_DEST in namespace and getattr(namespace, _PYLINT_DEST): - return pylint(getattr(namespace, _PYLINT_DEST), get_build_options(namespace)) + return pylint( + getattr(namespace, _PYLINT_DEST), + get_build_options(namespace), + namespace.pylint_output_format, + ) return 0 @@ -71,7 +82,9 @@ return apply_pylint(nmspc) -def pylint(modules: List[str], build_options: List[str]): +def pylint( + modules: List[str], build_options: List[str], output_format: str = "colorized" +): """Run pylint""" config = Config() mounts: List[Mount] @@ -96,7 +109,7 @@ config.local_tag, { "entrypoint": "pylint", - "command": ["--output-format=colorized"] + modules, + "command": [f"--output-format={output_format}"] + modules, # needed to write in the cache "user": "root", "mounts": mounts,