add impala-flake8

Add flake8 and dependencies to impala-python. The versions are
compatible with Python 2.6.6. Add the impala-flake8 entry point, similar
to impala-python.

Add setup.cfg which defines flake8 special rules and exemptions. They
are added to support 2-space indents and a max line length of 90.

Contributors writing Python can use impala-flake8 to look for formatting
mistakes. The two most common uses would be:

impala-flake8 myfile.py
or
git diff HEAD^ myfile.py | impala-flake8 --diff

In the second usage, flake8 will only examine lines changed. This allows
a contributor to fix their own code and not be penalized by flake8
violations that may already be present (though they are encouraged to
fix them if they can!)

Change-Id: Ib4ce9eca6f8b55eaec1c96e7db1ff630ac016be0
Reviewed-on: http://gerrit.cloudera.org:8080/10182
Reviewed-by: Michael Brown <mikeb@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Michael Brown
2018-04-23 13:37:20 -07:00
committed by Impala Public Jenkins
parent b56ac8f0a0
commit 2fb73f94b4
3 changed files with 47 additions and 0 deletions

21
bin/impala-flake8 Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
source "$(dirname "$0")/impala-python-common.sh"
exec "$PY_DIR/env/bin/flake8" "$@"

View File

@@ -34,6 +34,10 @@ boto3 == 1.2.3
cm-api == 10.0.0
# Already available as part of python on Linux.
readline == 6.2.4.1; sys_platform == 'darwin'
flake8 == 2.6.2
mccabe == 0.3.1
pycodestyle == 2.0.0
pyflakes == 1.2.3
Flask == 0.10.1
Jinja2 == 2.8
MarkupSafe == 0.23

22
setup.cfg Normal file
View File

@@ -0,0 +1,22 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
[flake8]
# These are ignored in order to support 2-space indents.
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
ignore = E111,E114
# Change from default to conform to Apache Impala line length.
max-line-length = 90