Just use flake8 instead of hacking
We don't use hacking in Infra. Use flake8 instead.
Change-Id: I04ac08a0c4218398b43e906a6d65f75b3ff104c3
diff --git a/jeepyb/cmd/close_pull_requests.py b/jeepyb/cmd/close_pull_requests.py
index 4ead4ad..6e24bc5 100644
--- a/jeepyb/cmd/close_pull_requests.py
+++ b/jeepyb/cmd/close_pull_requests.py
@@ -44,7 +44,7 @@
import logging
import os
-import jeepyb.log as l
+import jeepyb.log
import jeepyb.projects as p
import jeepyb.utils as u
@@ -67,12 +67,12 @@
def main():
parser = argparse.ArgumentParser()
- l.setup_logging_arguments(parser)
+ jeepyb.log.setup_logging_arguments(parser)
parser.add_argument('--message-file', dest='message_file', default=None,
help='The close pull request message')
args = parser.parse_args()
- l.configure_logging(args)
+ jeepyb.log.configure_logging(args)
if args.message_file:
try:
@@ -136,5 +136,6 @@
issue.create_comment(pull_request_text % vars)
req.edit(state="closed")
+
if __name__ == "__main__":
main()
diff --git a/jeepyb/cmd/create_hound_config.py b/jeepyb/cmd/create_hound_config.py
index 601ba74..373ae02 100644
--- a/jeepyb/cmd/create_hound_config.py
+++ b/jeepyb/cmd/create_hound_config.py
@@ -19,14 +19,14 @@
import json
import os
+import jeepyb.utils as u
+
# Python2 has unicode as a builtin
# Python3 does not
import sys
if sys.version_info[0] >= 3:
unicode = str
-import jeepyb.utils as u
-
PROJECTS_YAML = os.environ.get('PROJECTS_YAML', '/home/hound/projects.yaml')
GIT_SERVER = os.environ.get('GIT_BASE', 'opendev.org')
diff --git a/jeepyb/cmd/expire_old_reviews.py b/jeepyb/cmd/expire_old_reviews.py
index 5a62c05..3f81386 100644
--- a/jeepyb/cmd/expire_old_reviews.py
+++ b/jeepyb/cmd/expire_old_reviews.py
@@ -22,16 +22,16 @@
import logging
import paramiko
-import jeepyb.log as l
+import jeepyb.log
logger = logging.getLogger('expire_reviews')
def expire_patch_set(ssh, patch_id, patch_subject):
- message = ('Code review expired due to no recent activity'
- ' after a negative review. It can be restored using'
- ' the \`Restore Change\` button under the Patch Set'
- ' on the web interface.')
+ message = ("Code review expired due to no recent activity"
+ " after a negative review. It can be restored using"
+ " the 'Restore Change' button under the Patch Set"
+ " on the web interface.")
command = ('gerrit review --abandon '
'--message="{message}" {patch_id}').format(
message=message,
@@ -50,9 +50,9 @@
parser.add_argument('ssh_key', help='The gerrit admin SSH key file')
parser.add_argument('--age', dest='age', default='1w',
help='The minimum age of a review to expire')
- l.setup_logging_arguments(parser)
+ jeepyb.log.setup_logging_arguments(parser)
options = parser.parse_args()
- l.configure_logging(options)
+ jeepyb.log.configure_logging(options)
GERRIT_USER = options.user
GERRIT_SSH_KEY = options.ssh_key
@@ -85,5 +85,6 @@
logger.info('End expire review')
+
if __name__ == "__main__":
main()
diff --git a/jeepyb/cmd/manage_projects.py b/jeepyb/cmd/manage_projects.py
index d4362c1..3b75eb0 100644
--- a/jeepyb/cmd/manage_projects.py
+++ b/jeepyb/cmd/manage_projects.py
@@ -65,7 +65,7 @@
import gerritlib.gerrit
import github
-import jeepyb.log as l
+import jeepyb.log
import jeepyb.utils as u
registry = u.ProjectsRegistry()
@@ -415,13 +415,13 @@
def main():
parser = argparse.ArgumentParser(description='Manage projects')
- l.setup_logging_arguments(parser)
+ jeepyb.log.setup_logging_arguments(parser)
parser.add_argument('--nocleanup', action='store_true',
help='do not remove temp directories')
parser.add_argument('projects', metavar='project', nargs='*',
help='name of project(s) to process')
args = parser.parse_args()
- l.configure_logging(args)
+ jeepyb.log.configure_logging(args)
default_has_github = registry.get_defaults('has-github', True)
diff --git a/jeepyb/cmd/notify_impact.py b/jeepyb/cmd/notify_impact.py
index f30f042..611d332 100644
--- a/jeepyb/cmd/notify_impact.py
+++ b/jeepyb/cmd/notify_impact.py
@@ -332,5 +332,6 @@
if impacted(git_log, args.impact):
process_impact(git_log, args, config)
+
if __name__ == "__main__":
main()
diff --git a/jeepyb/cmd/openstackwatch.py b/jeepyb/cmd/openstackwatch.py
index 1064fc7..f7782d6 100644
--- a/jeepyb/cmd/openstackwatch.py
+++ b/jeepyb/cmd/openstackwatch.py
@@ -78,6 +78,7 @@
OUTPUT_MODE)
return ret
+
try:
conffile = sys.argv[1]
except IndexError:
@@ -174,5 +175,6 @@
else:
print(content)
+
if __name__ == '__main__':
main()
diff --git a/jeepyb/cmd/register_zanata_projects.py b/jeepyb/cmd/register_zanata_projects.py
index 6d64625..b737909 100644
--- a/jeepyb/cmd/register_zanata_projects.py
+++ b/jeepyb/cmd/register_zanata_projects.py
@@ -18,7 +18,7 @@
import logging
import os
-import jeepyb.log as l
+import jeepyb.log
import jeepyb.projects as p
import jeepyb.translations as t
import jeepyb.utils as u
@@ -33,9 +33,9 @@
def main():
parser = argparse.ArgumentParser(description='Register projects in Zanata')
- l.setup_logging_arguments(parser)
+ jeepyb.log.setup_logging_arguments(parser)
args = parser.parse_args()
- l.configure_logging(args)
+ jeepyb.log.configure_logging(args)
registry = u.ProjectsRegistry(PROJECTS_YAML)
rest_service = t.ZanataRestService(ZANATA_URL, ZANATA_USER, ZANATA_KEY)
diff --git a/jeepyb/cmd/track_upstream.py b/jeepyb/cmd/track_upstream.py
index 65751b7..6cd1e6a 100644
--- a/jeepyb/cmd/track_upstream.py
+++ b/jeepyb/cmd/track_upstream.py
@@ -57,7 +57,7 @@
import gerritlib.gerrit
-import jeepyb.log as l
+import jeepyb.log
import jeepyb.utils as u
registry = u.ProjectsRegistry()
@@ -142,13 +142,13 @@
def main():
parser = argparse.ArgumentParser(description='Manage projects')
- l.setup_logging_arguments(parser)
+ jeepyb.log.setup_logging_arguments(parser)
parser.add_argument('--nocleanup', action='store_true',
help='do not remove temp directories')
parser.add_argument('projects', metavar='project', nargs='*',
help='name of project(s) to process')
args = parser.parse_args()
- l.configure_logging(args)
+ jeepyb.log.configure_logging(args)
JEEPYB_CACHE_DIR = registry.get_defaults('jeepyb-cache-dir',
'/var/lib/jeepyb')
@@ -226,5 +226,6 @@
finally:
os.unlink(ssh_env['GIT_SSH'])
+
if __name__ == "__main__":
main()
diff --git a/jeepyb/cmd/trivial_rebase.py b/jeepyb/cmd/trivial_rebase.py
index 19e192b..2c8bfef 100644
--- a/jeepyb/cmd/trivial_rebase.py
+++ b/jeepyb/cmd/trivial_rebase.py
@@ -282,5 +282,6 @@
SuExec(options, approval["account_id"], ' '.join(gerrit_approve_cmd))
sys.exit(0)
+
if __name__ == "__main__":
main()
diff --git a/jeepyb/cmd/update_blueprint.py b/jeepyb/cmd/update_blueprint.py
index 0649dff..5c6590a 100644
--- a/jeepyb/cmd/update_blueprint.py
+++ b/jeepyb/cmd/update_blueprint.py
@@ -59,6 +59,7 @@
c.readfp(fp)
return c
+
GERRIT_CONFIG = get_broken_config(GERRIT_CONFIG)
SECURE_CONFIG = get_broken_config(GERRIT_SECURE_CONFIG)
DB_HOST = GERRIT_CONFIG.get("database", "hostname")
@@ -169,5 +170,6 @@
find_specs(lpconn, conn, args)
+
if __name__ == "__main__":
main()
diff --git a/jeepyb/cmd/welcome_message.py b/jeepyb/cmd/welcome_message.py
index 3694c89..b39c454 100644
--- a/jeepyb/cmd/welcome_message.py
+++ b/jeepyb/cmd/welcome_message.py
@@ -31,7 +31,7 @@
import paramiko
import jeepyb.gerritdb
-import jeepyb.log as l
+import jeepyb.log
BASE_DIR = '/home/gerrit2/review_site'
@@ -158,16 +158,17 @@
parser.add_argument('--dryrun', dest='dryrun', action='store_true')
parser.add_argument('--no-dryrun', dest='dryrun', action='store_false')
parser.set_defaults(dryrun=False)
- l.setup_logging_arguments(parser)
+ jeepyb.log.setup_logging_arguments(parser)
args = parser.parse_args()
- l.configure_logging(args)
+ jeepyb.log.configure_logging(args)
# they're a first-timer, post the message on 1st patchset
if is_newbie(args.uploader) and args.patchset == '1' and not args.dryrun:
post_message(args.commit, args.ssh_user, args.ssh_key,
args.message_file)
+
if __name__ == "__main__":
main()
diff --git a/test-requirements.txt b/test-requirements.txt
index d528919..117f7a3 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,4 +1,4 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-hacking<0.11,>=0.10.2
+flake8
diff --git a/tox.ini b/tox.ini
index 835b4ac..46bd1ce 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,6 +18,7 @@
[flake8]
# E125 and H are intentionally ignored
-ignore = E125,H
+# W503 is a mistake in flake8
+ignore = E125,H,W503,W504
show-source = True
exclude = .venv,.tox,dist,doc,build,*.egg