Bumped flake8
- Upgraded hacking(flake8) - Added more modern tox linters environment (pep8 alias) - Temporary added skips for broken newer rules - Fixed few basic rule violations - Moved flake8 config to setup.cfg (tox.ini is not recommended) Change-Id: I75b3ce5d2ce965a9dc5bdfaa49b2aacd8f0195ad
This commit is contained in:
parent
6fc19ee5b9
commit
f68a8719af
@ -15,8 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
# The configuration file should look like:
|
|
||||||
"""
|
"""
|
||||||
|
The configuration file should look like:
|
||||||
|
```
|
||||||
[ircbot]
|
[ircbot]
|
||||||
nick=NICKNAME
|
nick=NICKNAME
|
||||||
pass=PASSWORD
|
pass=PASSWORD
|
||||||
@ -31,16 +32,16 @@ user=gerrit2
|
|||||||
[data_source[
|
[data_source[
|
||||||
es_url=URLofELASTICSEARCH
|
es_url=URLofELASTICSEARCH
|
||||||
db_uri=SQLALCHEMY_URI_TO_SUBUNIT2SQL
|
db_uri=SQLALCHEMY_URI_TO_SUBUNIT2SQL
|
||||||
"""
|
```
|
||||||
|
|
||||||
# The yaml channel config should look like:
|
# The yaml channel config should look like:
|
||||||
"""
|
```
|
||||||
openstack-qa:
|
openstack-qa:
|
||||||
events:
|
events:
|
||||||
- positive
|
- positive
|
||||||
- negative
|
- negative
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import daemon
|
import daemon
|
||||||
import os
|
import os
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six.moves import configparser
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from six.moves import configparser
|
||||||
|
|
||||||
DEFAULT_INDEX_FORMAT = 'logstash-%Y.%m.%d'
|
DEFAULT_INDEX_FORMAT = 'logstash-%Y.%m.%d'
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ INCLUDED_PROJECTS_REGEX = "(^openstack/|devstack|grenade)"
|
|||||||
# Let's value legibility over pep8 line width here...
|
# Let's value legibility over pep8 line width here...
|
||||||
ALL_FAILS_QUERY = (
|
ALL_FAILS_QUERY = (
|
||||||
'('
|
'('
|
||||||
'(filename:"job-output.txt" AND message:"POST-RUN END" AND message:"playbooks/base/post.yaml")' # flake8: noqa
|
'(filename:"job-output.txt" AND message:"POST-RUN END" AND message:"playbooks/base/post.yaml")' # noqa E501
|
||||||
' OR '
|
' OR '
|
||||||
'(filename:"console.html" AND (message:"[Zuul] Job complete" OR message:"[SCP] Copying console log" OR message:"Grabbing consoleLog"))' # flake8: noqa
|
'(filename:"console.html" AND (message:"[Zuul] Job complete" OR message:"[SCP] Copying console log" OR message:"Grabbing consoleLog"))' # noqa E501
|
||||||
')'
|
')'
|
||||||
' AND build_status:"FAILURE"'
|
' AND build_status:"FAILURE"'
|
||||||
' AND build_queue:"gate"'
|
' AND build_queue:"gate"'
|
||||||
@ -130,7 +130,8 @@ class Config(object):
|
|||||||
if config.has_section('gerrit'):
|
if config.has_section('gerrit'):
|
||||||
self.gerrit_user = config.get('gerrit', 'user')
|
self.gerrit_user = config.get('gerrit', 'user')
|
||||||
self.gerrit_query_file = config.get('gerrit', 'query_file')
|
self.gerrit_query_file = config.get('gerrit', 'query_file')
|
||||||
# workaround for python api change https://docs.python.org/3/library/configparser.html#fallback-values
|
# workaround for python api change:
|
||||||
|
# https://docs.python.org/3/library/configparser.html#fallback-values
|
||||||
try:
|
try:
|
||||||
self.gerrit_host = config.get('gerrit',
|
self.gerrit_host = config.get('gerrit',
|
||||||
'host',
|
'host',
|
||||||
|
@ -227,7 +227,7 @@ class Stream(object):
|
|||||||
# these items. It's orthoginal to non voting ES searching.
|
# these items. It's orthoginal to non voting ES searching.
|
||||||
if " (non-voting)" in line:
|
if " (non-voting)" in line:
|
||||||
continue
|
continue
|
||||||
m = re.search("- ([\w-]+)\s*(http://\S+)\s*:\s*FAILURE", line)
|
m = re.search(r"- ([\w-]+)\s*(http://\S+)\s*:\s*FAILURE", line)
|
||||||
if m:
|
if m:
|
||||||
failed_tests.append(FailJob(m.group(1), m.group(2)))
|
failed_tests.append(FailJob(m.group(1), m.group(2)))
|
||||||
return failed_tests
|
return failed_tests
|
||||||
|
@ -78,9 +78,9 @@ def result_ready(change, patchset, name, short_uuid):
|
|||||||
# TODO(dmsimard): Revisit this query once Zuul v2 is no longer supported
|
# TODO(dmsimard): Revisit this query once Zuul v2 is no longer supported
|
||||||
# Let's value legibility over pep8 line width here...
|
# Let's value legibility over pep8 line width here...
|
||||||
query = (
|
query = (
|
||||||
'((filename:"job-output.txt" AND message:"POST-RUN END" AND message:"project-config/playbooks/base/post-ssh.yaml")' # flake8: noqa
|
'((filename:"job-output.txt" AND message:"POST-RUN END" AND message:"project-config/playbooks/base/post-ssh.yaml")' # noqa E501
|
||||||
' OR '
|
' OR '
|
||||||
'(filename:"console.html" AND (message:"[Zuul] Job complete" OR message:"[SCP] Copying console log" OR message:"Grabbing consoleLog")))' # flake8: noqa
|
'(filename:"console.html" AND (message:"[Zuul] Job complete" OR message:"[SCP] Copying console log" OR message:"Grabbing consoleLog")))' # noqa E501
|
||||||
' AND build_status:"FAILURE"'
|
' AND build_status:"FAILURE"'
|
||||||
' AND build_change:"{change}"'
|
' AND build_change:"{change}"'
|
||||||
' AND build_patchset:"{patchset}"'
|
' AND build_patchset:"{patchset}"'
|
||||||
|
13
setup.cfg
13
setup.cfg
@ -50,3 +50,16 @@ input_file = elastic_recheck/locale/elastic-recheck.pot
|
|||||||
keywords = _ gettext ngettext l_ lazy_gettext
|
keywords = _ gettext ngettext l_ lazy_gettext
|
||||||
mapping_file = babel.cfg
|
mapping_file = babel.cfg
|
||||||
output_file = elastic_recheck/locale/elastic-recheck.pot
|
output_file = elastic_recheck/locale/elastic-recheck.pot
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
ignore =
|
||||||
|
# These are ignored intentionally in infra projects;
|
||||||
|
# please don't submit patches that solely correct them or enable them.
|
||||||
|
E124,E125,E129,E252,E402,E741,H,W503,W504
|
||||||
|
# TODO(ssbarnea): Remove temporary added ignores during flake8 upgrade:
|
||||||
|
E123 # E123 closing bracket does not match indentation of opening bracket's line
|
||||||
|
F632 # F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
|
||||||
|
N802 # N802 function name {} should be lowercase
|
||||||
|
N806 # N806 variable '{}' in function should be lowercase
|
||||||
|
N813 # N813 camelcase '{}' imported as lowercase '{}'
|
||||||
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
hacking>=0.12.0,!=0.13.0,<0.14
|
hacking>=3.1.0,<3.2.0; python_version>='3.5'
|
||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
fixtures>=3.0.0
|
fixtures>=3.0.0
|
||||||
python-subunit
|
python-subunit
|
||||||
|
@ -74,7 +74,7 @@ def collect_rechecks(gerrit, days="14"):
|
|||||||
# bail early if the comment is outside the ER window
|
# bail early if the comment is outside the ER window
|
||||||
continue
|
continue
|
||||||
|
|
||||||
m = re.search('recheck (no bug|bug (\#)?(?P<bugno>\d+))$',
|
m = re.search(r'recheck (no bug|bug (\#)?(?P<bugno>\d+))$',
|
||||||
comment['message'])
|
comment['message'])
|
||||||
if m:
|
if m:
|
||||||
dev = None
|
dev = None
|
||||||
@ -130,5 +130,6 @@ def main():
|
|||||||
changes = cross_ref_with_er(changes, opts.dir)
|
changes = cross_ref_with_er(changes, opts.dir)
|
||||||
summarize_changes(changes)
|
summarize_changes(changes)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
23
tox.ini
23
tox.ini
@ -1,6 +1,6 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
envlist = pep8,py37,py36,py27,queries,docs
|
envlist = linters,py38,py37,py36,py27,queries,docs
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
@ -20,10 +20,6 @@ commands = python setup.py testr --slowest --testr-args='{posargs} tests.functio
|
|||||||
basepython = python3
|
basepython = python3
|
||||||
commands = python setup.py testr --slowest --testr-args='{posargs} tests.functional.test_queries'
|
commands = python setup.py testr --slowest --testr-args='{posargs} tests.functional.test_queries'
|
||||||
|
|
||||||
[testenv:pep8]
|
|
||||||
basepython = python3
|
|
||||||
commands = flake8
|
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
@ -37,13 +33,6 @@ basepython = python3
|
|||||||
# test to run the bot as a non voting foreground process
|
# test to run the bot as a non voting foreground process
|
||||||
commands = elastic-recheck -f -n --noirc elasticRecheck.conf
|
commands = elastic-recheck -f -n --noirc elasticRecheck.conf
|
||||||
|
|
||||||
[flake8]
|
|
||||||
# E125 Skipped because it's an overreach (and anti-emacs)
|
|
||||||
# E123 Skipped because it decreases clarity in many cases
|
|
||||||
|
|
||||||
ignore = E123,E125
|
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps = -r{toxinidir}/doc/requirements.txt
|
||||||
@ -57,3 +46,13 @@ basepython = python3
|
|||||||
# separately, outside of the requirements files.
|
# separately, outside of the requirements files.
|
||||||
deps = bindep
|
deps = bindep
|
||||||
commands = bindep test
|
commands = bindep test
|
||||||
|
|
||||||
|
[testenv:linters]
|
||||||
|
basepython = python3
|
||||||
|
commands = flake8
|
||||||
|
|
||||||
|
# deprecated, use linters instead
|
||||||
|
[testenv:pep8]
|
||||||
|
basepython = python3
|
||||||
|
envdir = {toxworkdir}/linters
|
||||||
|
commands = {[testenv:linters]commands}
|
||||||
|
@ -97,6 +97,7 @@ def main():
|
|||||||
while True:
|
while True:
|
||||||
httpd.handle_request()
|
httpd.handle_request()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user