Loading .lint +2 −0 Original line number Diff line number Diff line [mypy] [flake8] max-line-length = 92 max-doc-length = 92 Loading .pre-commit-config.yaml +13 −2 Original line number Diff line number Diff line Loading @@ -75,8 +75,19 @@ repos: - flake8-sfs - flake8-tabs - repo: . rev: v0.3 - repo: https://code.kodo.org.uk/dom/pre-commit-pylint rev: v2.6.0 hooks: - id: pylint args: ["--fail-under=9.0", "--rcfile=.lint"] - repo: local hooks: - id: mypy name: Mypy types: [python] language: system entry: ./pre_commit_mypy.py args: ["--config-file=.lint"] require_serial: true verbose: true .pre-commit-hooks.yaml +4 −4 Original line number Diff line number Diff line - id: pylint name: PyLint entry: pre-commit-pylint - id: mypy name: Mypy types: [python] language: python entry: pre-commit-mypy require_serial: true types: [python] verbose: true README.md +14 −14 Original line number Diff line number Diff line [![licence-badge]](/LICENCE.txt) Pre-Commit Hook: Pylint ======================= Pre-Commit Hook: Mypy ===================== **An improved Pylint hook for [pre-commit][]** **An improved Mypy hook for [pre-commit][]** Unlike the official Pylint pre-commit hook, this hook installs dependencies so that Pylint Unlike the Mypy hook provided by pre-commit, this hook installs dependencies so that Mypy can analyse external calls properly and avoid warnings about missing modules. Loading @@ -15,10 +15,10 @@ Using with pre-commit Add the following to your `.pre-commit-config.yaml`: - repo: https://code.kodo.org.uk/dom/pre-commit-pylint rev: v2.6.0 - repo: https://code.kodo.org.uk/dom/pre-commit-mypy rev: v0.800 hooks: - id: pylint - id: mypy # args: [...] Loading @@ -26,8 +26,8 @@ Configuration ------------- Configuration is done by adding arguments to the hook in `.pre-commit-config.yaml`. Any arguments supported by [Pylint][pylint-cmdline] are allowed, along with a few others listed below. Any arguments supported by [Mypy][mypy-cmdline] are allowed, along with a few others listed below. ##### `--extras=[EXTRA[,EXTRA...]]` Loading @@ -36,14 +36,14 @@ listed below. **Argument:** A comma separated list of package extras to install. **Description:** Extras are named groups of optional extra dependencies listed in a project's metadata and normally added to the packaging configuration. If Pylint complains a project's metadata and normally added to the packaging configuration. If Mypy complains about being unable to find a module listed in an extras group, the group will need to be included here. ##### `--editable|--non-editable` **Description:** Enable or disable editable mode install of the package in the Pylint **Description:** Enable or disable editable mode install of the package in the Mypy environment. This is only available to packages using *setuptools* and is enabled by default when `setup.py` is detected. It may improve environment setup times. Loading @@ -58,6 +58,6 @@ default when `setup.py` is detected. It may improve environment setup times. https://pre-commit.com/ "pre-commit documentation" [pylint-cmdline]: http://pylint.pycqa.org/en/latest/user_guide/run.html#command-line-options "Pylint Command Line Options" [mypy-cmdline]: https://mypy.readthedocs.io/en/stable/command_line.html#command-line "Mypy Command Line Options" pre_commit_pylint.py→pre_commit_mypy.py100644 → 100755 +10 −8 Original line number Diff line number Diff line # Copyright 2020 Dominik Sekotill <dom.sekotill@kodo.org.uk> #!/usr/bin/env python3 # # Copyright 2020-2021 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """ Run pylint from pre-commit with project dependencies installed Run mypy from pre-commit with project dependencies installed """ import subprocess Loading @@ -13,9 +15,9 @@ import sys from os.path import isfile import click from pylint import lint from mypy.main import main as mypy __version__ = '0.3' __version__ = '0.0' @click.command(context_settings=dict( Loading @@ -31,9 +33,9 @@ __version__ = '0.3' default=isfile('setup.py'), help="Use the editable install (develop) feature provided by setuptools", ) @click.argument('pylint-options', nargs=-1, type=click.UNPROCESSED) def main(extras, editable, pylint_options): """Invoke Pylint on the given files after ensuring dependencies are up to date""" @click.argument('mypy-arguments', nargs=-1, type=click.UNPROCESSED) def main(extras, editable, mypy_arguments): """Invoke Mypy on the given files after ensuring dependencies are up to date""" join = ','.join cmd = ['pip', 'install', '--upgrade'] if editable: Loading @@ -53,7 +55,7 @@ def main(extras, editable, pylint_options): sys.stderr.write(exc.stderr) sys.exit(3) lint.Run(list(pylint_options)) mypy(None, stdout=sys.stdout, stderr=sys.stderr, args=mypy_arguments) if __name__ == '__main__': Loading Loading
.lint +2 −0 Original line number Diff line number Diff line [mypy] [flake8] max-line-length = 92 max-doc-length = 92 Loading
.pre-commit-config.yaml +13 −2 Original line number Diff line number Diff line Loading @@ -75,8 +75,19 @@ repos: - flake8-sfs - flake8-tabs - repo: . rev: v0.3 - repo: https://code.kodo.org.uk/dom/pre-commit-pylint rev: v2.6.0 hooks: - id: pylint args: ["--fail-under=9.0", "--rcfile=.lint"] - repo: local hooks: - id: mypy name: Mypy types: [python] language: system entry: ./pre_commit_mypy.py args: ["--config-file=.lint"] require_serial: true verbose: true
.pre-commit-hooks.yaml +4 −4 Original line number Diff line number Diff line - id: pylint name: PyLint entry: pre-commit-pylint - id: mypy name: Mypy types: [python] language: python entry: pre-commit-mypy require_serial: true types: [python] verbose: true
README.md +14 −14 Original line number Diff line number Diff line [![licence-badge]](/LICENCE.txt) Pre-Commit Hook: Pylint ======================= Pre-Commit Hook: Mypy ===================== **An improved Pylint hook for [pre-commit][]** **An improved Mypy hook for [pre-commit][]** Unlike the official Pylint pre-commit hook, this hook installs dependencies so that Pylint Unlike the Mypy hook provided by pre-commit, this hook installs dependencies so that Mypy can analyse external calls properly and avoid warnings about missing modules. Loading @@ -15,10 +15,10 @@ Using with pre-commit Add the following to your `.pre-commit-config.yaml`: - repo: https://code.kodo.org.uk/dom/pre-commit-pylint rev: v2.6.0 - repo: https://code.kodo.org.uk/dom/pre-commit-mypy rev: v0.800 hooks: - id: pylint - id: mypy # args: [...] Loading @@ -26,8 +26,8 @@ Configuration ------------- Configuration is done by adding arguments to the hook in `.pre-commit-config.yaml`. Any arguments supported by [Pylint][pylint-cmdline] are allowed, along with a few others listed below. Any arguments supported by [Mypy][mypy-cmdline] are allowed, along with a few others listed below. ##### `--extras=[EXTRA[,EXTRA...]]` Loading @@ -36,14 +36,14 @@ listed below. **Argument:** A comma separated list of package extras to install. **Description:** Extras are named groups of optional extra dependencies listed in a project's metadata and normally added to the packaging configuration. If Pylint complains a project's metadata and normally added to the packaging configuration. If Mypy complains about being unable to find a module listed in an extras group, the group will need to be included here. ##### `--editable|--non-editable` **Description:** Enable or disable editable mode install of the package in the Pylint **Description:** Enable or disable editable mode install of the package in the Mypy environment. This is only available to packages using *setuptools* and is enabled by default when `setup.py` is detected. It may improve environment setup times. Loading @@ -58,6 +58,6 @@ default when `setup.py` is detected. It may improve environment setup times. https://pre-commit.com/ "pre-commit documentation" [pylint-cmdline]: http://pylint.pycqa.org/en/latest/user_guide/run.html#command-line-options "Pylint Command Line Options" [mypy-cmdline]: https://mypy.readthedocs.io/en/stable/command_line.html#command-line "Mypy Command Line Options"
pre_commit_pylint.py→pre_commit_mypy.py100644 → 100755 +10 −8 Original line number Diff line number Diff line # Copyright 2020 Dominik Sekotill <dom.sekotill@kodo.org.uk> #!/usr/bin/env python3 # # Copyright 2020-2021 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """ Run pylint from pre-commit with project dependencies installed Run mypy from pre-commit with project dependencies installed """ import subprocess Loading @@ -13,9 +15,9 @@ import sys from os.path import isfile import click from pylint import lint from mypy.main import main as mypy __version__ = '0.3' __version__ = '0.0' @click.command(context_settings=dict( Loading @@ -31,9 +33,9 @@ __version__ = '0.3' default=isfile('setup.py'), help="Use the editable install (develop) feature provided by setuptools", ) @click.argument('pylint-options', nargs=-1, type=click.UNPROCESSED) def main(extras, editable, pylint_options): """Invoke Pylint on the given files after ensuring dependencies are up to date""" @click.argument('mypy-arguments', nargs=-1, type=click.UNPROCESSED) def main(extras, editable, mypy_arguments): """Invoke Mypy on the given files after ensuring dependencies are up to date""" join = ','.join cmd = ['pip', 'install', '--upgrade'] if editable: Loading @@ -53,7 +55,7 @@ def main(extras, editable, pylint_options): sys.stderr.write(exc.stderr) sys.exit(3) lint.Run(list(pylint_options)) mypy(None, stdout=sys.stdout, stderr=sys.stderr, args=mypy_arguments) if __name__ == '__main__': Loading