diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/tutorial.rst | 1 | ||||
-rw-r--r-- | doc/user_guide/index.rst | 1 | ||||
-rw-r--r-- | doc/user_guide/pre-commit-integration.rst | 46 |
3 files changed, 48 insertions, 0 deletions
diff --git a/doc/tutorial.rst b/doc/tutorial.rst index b7ff5559c..156fea427 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -1,3 +1,4 @@ +.. _tutorial: ======== Tutorial diff --git a/doc/user_guide/index.rst b/doc/user_guide/index.rst index e25db0f99..95daa4748 100644 --- a/doc/user_guide/index.rst +++ b/doc/user_guide/index.rst @@ -12,3 +12,4 @@ User Guide message-control options ide-integration + pre-commit-integration diff --git a/doc/user_guide/pre-commit-integration.rst b/doc/user_guide/pre-commit-integration.rst new file mode 100644 index 000000000..62dfbcfd0 --- /dev/null +++ b/doc/user_guide/pre-commit-integration.rst @@ -0,0 +1,46 @@ +.. _pre-commit-integration: + +Pre-commit integration +====================== + +``pylint`` can be used as a `pre-commit <https://pre-commit.com>`_ hook. + +Since ``pylint`` needs to import modules and dependencies to work correctly, the +hook only works with a local installation of ``pylint`` (in your environment). +If you installed ``pylint`` locally it can be added to ``.pre-commit-config.yaml`` +as follows: + +.. sourcecode:: yaml + + - repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + args: + [ + "-rn", # Only display messages + "-sn", # Don't display the score + ] + +You can use ``args`` to pass command line arguments as described in the :ref:`tutorial`. +A hook with more arguments could look something like this: + +.. sourcecode:: yaml + + - repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + args: + [ + "-rn", # Only display messages + "-sn", # Don't display the score + "--rcfile=pylintrc", # Link to your config file + "--load-plugins=pylint.extensions.docparams", # Load an extension + ] |