Skip to content

Commit

Permalink
[cli] Setup pylint: run 'ti lint' to obtain linting results (#1846)
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate authored Sep 19, 2020
1 parent 1b78447 commit 0ff566d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MESSAGES CONTROL]
disable=invalid-name, missing-function-docstring, missing-class-docstring, missing-module-docstring, unused-wildcard-import, cyclic-import, blacklisted-name, import-outside-toplevel
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN apt-get update && \
libtinfo5

# Install Taichi's Python dependencies
RUN python3 -m pip install --user setuptools astpretty astor pybind11 Pillow dill
RUN python3 -m pip install --user setuptools astor pybind11 pylint sourceinspect
RUN python3 -m pip install --user pytest pytest-rerunfailures pytest-xdist yapf
RUN python3 -m pip install --user numpy GitPython coverage colorama autograd

Expand Down
4 changes: 3 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ void build_taichi() {
$CC --version
$CXX --version
echo $WORKSPACE
$PYTHON_EXECUTABLE -m pip install twine numpy Pillow scipy pybind11 colorama setuptools astor matplotlib pytest autograd GitPython dill --user
$PYTHON_EXECUTABLE -m pip install --user setuptools astor pybind11 pylint sourceinspect
$PYTHON_EXECUTABLE -m pip install --user pytest pytest-rerunfailures pytest-xdist yapf
$PYTHON_EXECUTABLE -m pip install --user numpy GitPython coverage colorama autograd
export TAICHI_REPO_DIR=$WORKSPACE/
echo $TAICHI_REPO_DIR
export PYTHONPATH=$TAICHI_REPO_DIR/python
Expand Down
2 changes: 1 addition & 1 deletion docs/dev_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Installing Dependencies

.. code-block:: bash
python3 -m pip install --user setuptools astor pybind11 Pillow sourceinspect
python3 -m pip install --user setuptools astor pybind11 pylint sourceinspect
python3 -m pip install --user pytest pytest-rerunfailures pytest-xdist yapf
python3 -m pip install --user numpy GitPython coverage colorama autograd
Expand Down
19 changes: 19 additions & 0 deletions python/taichi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,25 @@ def local_scope():

local_scope()

@register
def lint(self, arguments: list = sys.argv[2:]):
"""Run pylint checker for the Python codebase of Taichi"""
parser = argparse.ArgumentParser(prog='ti lint',
description=f"{self.lint.__doc__}")
# TODO: support arguments for lint specific files
args = parser.parse_args(arguments)

options = [os.path.dirname(__file__)]

from multiprocessing import cpu_count
threads = min(8, cpu_count())
options += ['-j', str(threads)]

# http://pylint.pycqa.org/en/latest/user_guide/run.html
# TODO: support redirect output to lint.log
import pylint.lint
pylint.lint.Run(options)


def main():
cli = TaichiMain()
Expand Down

0 comments on commit 0ff566d

Please sign in to comment.