From: Thanh Ha Date: Sun, 5 Mar 2017 02:36:58 +0000 (-0500) Subject: Add Python linting in coala X-Git-Tag: v0.0.6~2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F66%2F4066%2F1;p=releng%2Flftools.git Add Python linting in coala - Add Git Commit Bear to validate commit message - Make tox automatically download nltk data for GitCommitBear - Add Python Bears to validate Python code Change-Id: Ib50fa4ecaf282a751de38f149bf1e2992463a5f2 Signed-off-by: Thanh Ha --- diff --git a/.coafile b/.coafile index a22d3ffb..48dbdab5 100644 --- a/.coafile +++ b/.coafile @@ -1,11 +1,15 @@ [default] -bears = SpaceConsistencyBear +bears = SpaceConsistencyBear,GitCommitBear files = shell/* allow_trailing_whitespace = False enforce_newline_at_EOF = True indent_size = 4 use_spaces = yeah +[Python] +bears = BanditBear,PyCommentedCodeBear,PyDocStyleBear,PyFlakesBear,PyImportSortBear +files = lftools/**/*.py + [ShellCheck] bears = ShellCheckBear files = shell/* diff --git a/lftools/__init__.py b/lftools/__init__.py index e69de29b..ded0c116 100644 --- a/lftools/__init__.py +++ b/lftools/__init__.py @@ -0,0 +1,13 @@ +# @License EPL-1.0 +############################################################################## +# Copyright (c) 2017 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Thanh Ha - Initial implementation +############################################################################## +"""lftools package.""" diff --git a/lftools/cli.py b/lftools/cli.py index ff1ac7f1..c380a5e4 100644 --- a/lftools/cli.py +++ b/lftools/cli.py @@ -1,12 +1,29 @@ -import click +# @License EPL-1.0 +############################################################################## +# Copyright (c) 2017 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Thanh Ha - Initial implementation +############################################################################## +"""CLI main for lftools.""" import subprocess +import click + + @click.group() @click.pass_context @click.version_option() def cli(ctx): + """CLI entry point for lftools.""" pass + ############################################################################### # Shell ############################################################################### @@ -16,7 +33,7 @@ def cli(ctx): @click.argument('release-tag') @click.pass_context def version(ctx, command, release_tag): - """Version bump script for Maven based projects + """Version bump script for Maven based projects. Uses *release-tag* to bump versions for Maven projects. @@ -56,6 +73,7 @@ def version(ctx, command, release_tag): """ subprocess.call(['version', command, release_tag]) + cli.add_command(version) if __name__ == '__main__': diff --git a/tox.ini b/tox.ini index 18e4aa92..974a81a2 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ deps = coala coala-bears commands = + python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger coala --non-interactive [testenv:docs]