From 9602c600ab18062715700bb543ed84530a2f8632 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:52:31 +0000
Subject: [PATCH 1/18] flake8 fixes to pagure.api


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py
index 21eab81..6482699 100644
--- a/pagure/api/__init__.py
+++ b/pagure/api/__init__.py
@@ -187,14 +187,14 @@ def api_method(function):
 
             if err.error_code in [APIERROR.ENOCODE]:
                 output = {
-                        'error': err.error,
-                        'error_code': err.error_code.name
-                    }
+                    'error': err.error,
+                    'error_code': err.error_code.name
+                }
             else:
                 output = {
-                        'error': err.error_code.value,
-                        'error_code': err.error_code.name,
-                    }
+                    'error': err.error_code.value,
+                    'error_code': err.error_code.name,
+                }
 
             if err.errors:
                 output['errors'] = err.errors
diff --git a/pagure/api/group.py b/pagure/api/group.py
index 78ab1b2..24aacea 100644
--- a/pagure/api/group.py
+++ b/pagure/api/group.py
@@ -91,24 +91,24 @@ def api_view_group(group):
 
         {
           "creator": {
-            "default_email": "user1@example.com", 
+            "default_email": "user1@example.com",
             "emails": [
               "user1@example.com"
-            ], 
-            "fullname": "User1", 
+            ],
+            "fullname": "User1",
             "name": "user1"
-          }, 
-          "date_created": "1492011511", 
-          "description": "Some Group", 
-          "display_name": "Some Group", 
-          "group_type": "user", 
+          },
+          "date_created": "1492011511",
+          "description": "Some Group",
+          "display_name": "Some Group",
+          "group_type": "user",
           "members": [
-            "user1", 
+            "user1",
             "user2"
-          ], 
+          ],
           "name": "some_group_name"
         }
-    """
+    """  # noqa
     group = pagure.lib.search_groups(SESSION, group_name=group)
     if not group:
         raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOGROUP)
diff --git a/pagure/api/issue.py b/pagure/api/issue.py
index 89708fb..1497c75 100644
--- a/pagure/api/issue.py
+++ b/pagure/api/issue.py
@@ -18,8 +18,7 @@ import pagure.exceptions
 import pagure.lib
 
 from pagure import (
-    APP, SESSION, is_repo_committer, api_authenticated, urlpattern,
-    is_repo_admin
+    APP, SESSION, is_repo_committer, api_authenticated, urlpattern
 )
 from pagure.api import (
     API, api_method, api_login_required, api_login_optional, APIERROR
@@ -31,7 +30,8 @@ def _get_repo(repo_name, username=None, namespace=None):
     :param repo_name: name of repository
     :param username:
     :param namespace:
-    :raises pagure.exceptions.APIError: when repository doesn't exists or is disabled
+    :raises pagure.exceptions.APIError: when repository doesn't exists or
+        is disabled
     :return: repository name
     """
     repo = pagure.get_authorized_project(
@@ -372,7 +372,7 @@ def api_view_issues(repo, username=None, namespace=None):
             no_stones = True
         else:
             no_stones = False
-    priority =  flask.request.args.get('priority', None)
+    priority = flask.request.args.get('priority', None)
     since = flask.request.args.get('since', None)
     status = flask.request.args.get('status', None)
     tags = flask.request.args.getlist('tags')
@@ -667,7 +667,6 @@ def api_change_status_issue(repo, issueid, username=None, namespace=None):
     issue = _get_issue(repo, issueid)
     _check_issue_access_repo_commiter(issue)
 
-
     status = pagure.lib.get_issue_statuses(SESSION)
     form = pagure.forms.StatusForm(
         status=status,
@@ -724,9 +723,11 @@ def api_change_status_issue(repo, issueid, username=None, namespace=None):
 
 
 @API.route('/<repo>/issue/<int:issueid>/milestone', methods=['POST'])
-@API.route('/<namespace>/<repo>/issue/<int:issueid>/milestone', methods=['POST'])
 @API.route(
-    '/fork/<username>/<repo>/issue/<int:issueid>/milestone', methods=['POST'])
+    '/<namespace>/<repo>/issue/<int:issueid>/milestone', methods=['POST'])
+@API.route(
+    '/fork/<username>/<repo>/issue/<int:issueid>/milestone',
+    methods=['POST'])
 @API.route(
     '/fork/<username>/<namespace>/<repo>/issue/<int:issueid>/milestone',
     methods=['POST'])
@@ -770,7 +771,7 @@ def api_change_milestone_issue(repo, issueid, username=None, namespace=None):
           "message": "Successfully edited issue #1"
         }
 
-    """
+    """  # noqa
     output = {}
     repo = _get_repo(repo, username, namespace)
     _check_issue_tracker(repo)
diff --git a/pagure/api/project.py b/pagure/api/project.py
index cc5eb3e..797d2b8 100644
--- a/pagure/api/project.py
+++ b/pagure/api/project.py
@@ -165,7 +165,8 @@ def api_projects():
         private = flask.g.fas_user.username
 
     projects = pagure.lib.search_projects(
-        SESSION, username=username, fork=fork, tags=tags, pattern=pattern, private=private)
+        SESSION, username=username, fork=fork,
+        tags=tags, pattern=pattern, private=private)
 
     if not projects:
         raise pagure.exceptions.APIError(

From c17474c4a34c6d09bc7374a3ba8b70ef6a994405 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:52:31 +0000
Subject: [PATCH 2/18] flake8 fixes to pagure.cli


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py
index e80c76e..ee95bcc 100644
--- a/pagure/cli/admin.py
+++ b/pagure/cli/admin.py
@@ -56,7 +56,7 @@ def _parser_clear_hook_token(subparser):
 def _parser_admin_token_list(subparser):
     """ Set up the CLI argument parser for the admin-token list action. """
     local_parser = subparser.add_parser(
-        'list',  help="List the API admin token")
+        'list', help="List the API admin token")
     local_parser.add_argument(
         '--user',
         help="User to associate or associated with the token")
@@ -74,7 +74,7 @@ def _parser_admin_token_list(subparser):
 def _parser_admin_token_info(subparser):
     """ Set up the CLI argument parser for the admin-token info action. """
     local_parser = subparser.add_parser(
-        'info',  help="Provide some information about a specific API token")
+        'info', help="Provide some information about a specific API token")
     local_parser.add_argument(
         'token', help="API token")
     local_parser.set_defaults(func=do_info_admin_token)
@@ -84,7 +84,7 @@ def _parser_admin_token_expire(subparser):
     """ Set up the CLI argument parser for the admin-token expire action. """
     # Expire admin token
     local_parser = subparser.add_parser(
-        'expire',  help="Expire a specific API token")
+        'expire', help="Expire a specific API token")
     local_parser.add_argument(
         'token', help="API token")
     local_parser.set_defaults(func=do_expire_admin_token)

From 473519f455aa6b8edff12f3c6c1ac9b1b4dfaa5e Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:52:31 +0000
Subject: [PATCH 3/18] flake8 fixes to pagure.internal


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py
index abbdb96..11b0df2 100644
--- a/pagure/internal/__init__.py
+++ b/pagure/internal/__init__.py
@@ -10,8 +10,6 @@ Internal endpoints.
 
 """
 
-import shutil
-import tempfile
 import os
 
 import flask
@@ -22,13 +20,13 @@ from sqlalchemy.exc import SQLAlchemyError
 
 PV = flask.Blueprint('internal_ns', __name__, url_prefix='/pv')
 
-import pagure
-import pagure.exceptions
-import pagure.forms
-import pagure.lib
-import pagure.lib.git
-import pagure.ui.fork
-from pagure import is_repo_admin, authenticated
+import pagure  # noqa
+import pagure.exceptions  # noqa
+import pagure.forms  # noqa
+import pagure.lib  # noqa
+import pagure.lib.git  # noqa
+import pagure.ui.fork  # noqa
+from pagure import is_repo_admin, authenticated  # noqa
 
 
 MERGE_OPTIONS = {

From 5729b804db336ee9b913b9750de4c5717edb4812 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:52:31 +0000
Subject: [PATCH 4/18] flake8 fixes to pagure.hooks


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/hooks/__init__.py b/pagure/hooks/__init__.py
index d1d7215..62f214e 100644
--- a/pagure/hooks/__init__.py
+++ b/pagure/hooks/__init__.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 """
- (c) 2014 - Copyright Red Hat Inc
+ (c) 2014-2017 - Copyright Red Hat Inc
 
  Authors:
    Pierre-Yves Chibon <pingou@pingoured.fr>
@@ -9,7 +9,6 @@
 """
 
 import os
-import shutil
 import wtforms
 
 from pagure.exceptions import FileNotFoundException
diff --git a/pagure/hooks/default.py b/pagure/hooks/default.py
index 5d34a69..184820b 100644
--- a/pagure/hooks/default.py
+++ b/pagure/hooks/default.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 """
- (c) 2016 - Copyright Red Hat Inc
+ (c) 2016-2017 - Copyright Red Hat Inc
 
  Authors:
    Pierre-Yves Chibon <pingou@pingoured.fr>
@@ -17,10 +17,9 @@ except ImportError:
 from sqlalchemy.orm import relation
 from sqlalchemy.orm import backref
 
-import pagure.lib
-from pagure.hooks import BaseHook, RequiredIf
+from pagure.hooks import BaseHook
 from pagure.lib.model import BASE, Project
-from pagure import SESSION, APP, get_repo_path
+from pagure import get_repo_path
 
 
 class DefaultTable(BASE):
diff --git a/pagure/hooks/files/default_hook.py b/pagure/hooks/files/default_hook.py
index 7d5e05d..36cb3f4 100755
--- a/pagure/hooks/files/default_hook.py
+++ b/pagure/hooks/files/default_hook.py
@@ -18,11 +18,11 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure
-import pagure.exceptions
-import pagure.lib.link
+import pagure  # noqa
+import pagure.exceptions  # noqa
+import pagure.lib.link  # noqa
 
-from pagure.lib import REDIS
+from pagure.lib import REDIS  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
@@ -39,7 +39,7 @@ def run_as_post_receive_hook():
         print('namespace:', namespace)
 
     project = pagure.lib._get_project(
-            pagure.SESSION, repo, user=username, namespace=namespace)
+        pagure.SESSION, repo, user=username, namespace=namespace)
 
     for line in sys.stdin:
         if pagure.APP.config.get('HOOK_DEBUG', False):
@@ -75,13 +75,14 @@ def run_as_post_receive_hook():
 
         if REDIS:
             print('Sending to redis to log activity')
-            REDIS.publish('pagure.logcom',
+            REDIS.publish(
+                'pagure.logcom',
                 json.dumps({
                     'project': project.to_json(public=True),
                     'abspath': abspath,
                     'commits': commits,
-                }
-            ))
+                })
+            )
 
     try:
         # Reset the merge_status of all opened PR to refresh their cache
diff --git a/pagure/hooks/files/fedmsg_hook.py b/pagure/hooks/files/fedmsg_hook.py
index bc67959..b8a6052 100755
--- a/pagure/hooks/files/fedmsg_hook.py
+++ b/pagure/hooks/files/fedmsg_hook.py
@@ -1,12 +1,8 @@
 #!/usr/bin/env python
 
-import getpass
 import os
-import subprocess
 import sys
 
-from collections import defaultdict
-
 import fedmsg
 import fedmsg.config
 
@@ -16,8 +12,8 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure
-import pagure.lib.git
+import pagure  # noqa
+import pagure.lib.git  # noqa
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
 
diff --git a/pagure/hooks/files/git_multimail.py b/pagure/hooks/files/git_multimail.py
index 03b10bb..e7aa9a5 100755
--- a/pagure/hooks/files/git_multimail.py
+++ b/pagure/hooks/files/git_multimail.py
@@ -1,5 +1,7 @@
 #! /usr/bin/env python2
 
+# flake8: noqa
+
 # Copyright (c) 2012-2014 Michael Haggerty and others
 # Derived from contrib/hooks/post-receive-email, which is
 # Copyright (c) 2007 Andy Parkins
diff --git a/pagure/hooks/files/pagure_block_unsigned.py b/pagure/hooks/files/pagure_block_unsigned.py
index 111b813..deb9d5a 100755
--- a/pagure/hooks/files/pagure_block_unsigned.py
+++ b/pagure/hooks/files/pagure_block_unsigned.py
@@ -8,20 +8,16 @@ statement.
 import os
 import sys
 
-from sqlalchemy.exc import SQLAlchemyError
-
-import sys
-sys.path.insert(0, '/home/pierrey/repos/gitrepo/pagure/')
 
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure
-import pagure.exceptions
-import pagure.lib.link
-import pagure.ui.plugins
+import pagure  # noqa
+import pagure.exceptions  # noqa
+import pagure.lib.link  # noqa
+import pagure.ui.plugins  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_force_commit_hook.py b/pagure/hooks/files/pagure_force_commit_hook.py
index 1fa5a20..ac6f9f6 100755
--- a/pagure/hooks/files/pagure_force_commit_hook.py
+++ b/pagure/hooks/files/pagure_force_commit_hook.py
@@ -7,18 +7,16 @@
 import os
 import sys
 
-from sqlalchemy.exc import SQLAlchemyError
-
 
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure
-import pagure.exceptions
-import pagure.lib.link
-import pagure.lib.plugins
+import pagure  # noqa
+import pagure.exceptions  # noqa
+import pagure.lib.link  # noqa
+import pagure.lib.plugins  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
@@ -34,14 +32,14 @@ def run_as_pre_receive_hook():
         print 'namspaces:', namespace
 
     repo = pagure.lib._get_project(
-            pagure.SESSION, reponame, user=username, namespace=namespace)
+        pagure.SESSION, reponame, user=username, namespace=namespace)
     if not repo:
         print 'Unknown repo %s of username: %s in namespace %s' % (
             reponame, username, namespace)
         sys.exit(1)
 
     plugin = pagure.lib.plugins.get_plugin('Block non fast-forward pushes')
-    dbobj = plugin.db_object()
+    plugin.db_object()
     # Get the list of branches
     branches = [
         branch.strip()
diff --git a/pagure/hooks/files/pagure_hook.py b/pagure/hooks/files/pagure_hook.py
index 4da7c4c..115db53 100755
--- a/pagure/hooks/files/pagure_hook.py
+++ b/pagure/hooks/files/pagure_hook.py
@@ -17,9 +17,9 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure
-import pagure.exceptions
-import pagure.lib.link
+import pagure  # noqa
+import pagure.exceptions  # noqa
+import pagure.lib.link  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_hook_requests.py b/pagure/hooks/files/pagure_hook_requests.py
index e8f4dd5..f9b1237 100755
--- a/pagure/hooks/files/pagure_hook_requests.py
+++ b/pagure/hooks/files/pagure_hook_requests.py
@@ -7,9 +7,7 @@ based on the information pushed in the requests git repository.
 
 import json
 import os
-import re
 import sys
-import subprocess
 
 
 # We need to access the database
@@ -18,7 +16,7 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure.lib.git
+import pagure.lib.git  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_hook_tickets.py b/pagure/hooks/files/pagure_hook_tickets.py
index 7fb8a50..2233851 100755
--- a/pagure/hooks/files/pagure_hook_tickets.py
+++ b/pagure/hooks/files/pagure_hook_tickets.py
@@ -8,9 +8,7 @@ from __future__ import print_function
 
 import json
 import os
-import re
 import sys
-import subprocess
 
 
 # We need to access the database
@@ -18,10 +16,10 @@ if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
-import pagure
-import pagure.lib.git
+import pagure  # noqa
+import pagure.lib.git  # noqa
 
-from pagure.lib import REDIS
+from pagure.lib import REDIS  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
@@ -64,7 +62,8 @@ def run_as_post_receive_hook():
 
         if REDIS:
             print('Sending to redis to load the data')
-            REDIS.publish('pagure.loadjson',
+            REDIS.publish(
+                'pagure.loadjson',
                 json.dumps({
                     'project': project.to_json(public=True),
                     'abspath': abspath,
diff --git a/pagure/hooks/files/rtd_hook.py b/pagure/hooks/files/rtd_hook.py
index c4c7371..fa6dcb1 100755
--- a/pagure/hooks/files/rtd_hook.py
+++ b/pagure/hooks/files/rtd_hook.py
@@ -9,18 +9,16 @@ import sys
 
 import requests
 
-from sqlalchemy.exc import SQLAlchemyError
-
 
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure
-import pagure.exceptions
-import pagure.lib.link
-import pagure.lib.plugins
+import pagure  # noqa
+import pagure.exceptions  # noqa
+import pagure.lib.link  # noqa
+import pagure.lib.plugins  # noqa
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
@@ -36,12 +34,12 @@ def run_as_post_receive_hook():
         print 'namespace:', namespace
 
     repo = pagure.get_authorized_project(
-            pagure.SESSION, reponame, user=username, namespace=namespace)
+        pagure.SESSION, reponame, user=username, namespace=namespace)
     if not repo:
         print 'Unknown repo %s of username: %s' % (reponame, username)
         sys.exit(1)
 
-    plugin = pagure.lib.plugins.get_plugin('Read the Doc')
+    pagure.lib.plugins.get_plugin('Read the Doc')
     # Get the list of branches
     branches = [
         branch.strip()
diff --git a/pagure/hooks/irc.py b/pagure/hooks/irc.py
index 9a1033f..5871875 100644
--- a/pagure/hooks/irc.py
+++ b/pagure/hooks/irc.py
@@ -8,8 +8,6 @@
 
 """
 
-import os
-
 import sqlalchemy as sa
 import pygit2
 import wtforms
@@ -120,7 +118,7 @@ class Hook(BaseHook):
         '''
         repopaths = [get_repo_path(project)]
 
-        repo_obj = pygit2.Repository(repopaths[0])
+        repo_obj = pygit2.Repository(repopaths[0])  # noqa
 
         # Configure the hook
         # repo_obj.config.set_multivar()
@@ -136,6 +134,6 @@ class Hook(BaseHook):
             should be installed
 
         '''
-        repopaths = [get_repo_path(project)]
+        repopaths = [get_repo_path(project)]  # noqa
 
         # cls.base_remove(repopaths, 'irc')
diff --git a/pagure/hooks/pagure_ticket_hook.py b/pagure/hooks/pagure_ticket_hook.py
index 3a97688..00bd8d3 100644
--- a/pagure/hooks/pagure_ticket_hook.py
+++ b/pagure/hooks/pagure_ticket_hook.py
@@ -64,8 +64,9 @@ class PagureTicketHook(BaseHook):
     ''' Pagure ticket hook. '''
 
     name = 'Pagure tickets'
-    description = 'Pagure specific hook to update tickets stored in the database '\
-        'based on the information pushed in the tickets git repository.'
+    description = 'Pagure specific hook to update tickets stored in the '\
+        'database based on the information pushed in the tickets git '\
+        'repository.'
     form = PagureTicketsForm
     db_object = PagureTicketsTable
     backref = 'pagure_hook_tickets'

From 12805b27acd8980b5d7514b1e68fe11e56abfc48 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:52:31 +0000
Subject: [PATCH 5/18] flake8 fixes to pagure.lib


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py
index f18e577..ef279c4 100644
--- a/pagure/lib/__init__.py
+++ b/pagure/lib/__init__.py
@@ -1989,15 +1989,15 @@ def search_projects(
     # project is viewing the project
     elif isinstance(private, basestring) and private != username:
         projects = projects.filter(
-                sqlalchemy.or_(
-                    model.Project.private == False,
-                    sqlalchemy.and_(
-                        model.User.user == private,
-                        model.User.id == model.ProjectUser.user_id,
-                        model.ProjectUser.project_id == model.Project.id,
-                        model.Project.private == True,
-                    )
+            sqlalchemy.or_(
+                model.Project.private == False,
+                sqlalchemy.and_(
+                    model.User.user == private,
+                    model.User.id == model.ProjectUser.user_id,
+                    model.ProjectUser.project_id == model.Project.id,
+                    model.Project.private == True,
                 )
+            )
         )
 
     if fork is not None:
@@ -3389,7 +3389,7 @@ def text2markdown(text, extended=True, readme=False):
     md_processor = markdown.Markdown(
         safe_mode="escape",
         extensions=extensions,
-        extension_configs = {
+        extension_configs={
             'markdown.extensions.codehilite': {
                 'guess_lang': False,
             }
@@ -3460,7 +3460,7 @@ def clean_input(text, ignore=None):
             pass
         bleach_v[idx] = val
     if tuple(bleach_v) >= (1, 5, 0):
-        protocols=bleach.ALLOWED_PROTOCOLS + ['irc', 'ircs']
+        protocols = bleach.ALLOWED_PROTOCOLS + ['irc', 'ircs']
         kwargs['protocols'] = protocols
 
     return bleach.clean(text, **kwargs)
diff --git a/pagure/lib/git.py b/pagure/lib/git.py
index affa5e6..d4f7e00 100644
--- a/pagure/lib/git.py
+++ b/pagure/lib/git.py
@@ -709,7 +709,7 @@ def update_request_from_git(
     """
 
     repo = pagure.lib._get_project(
-            session, reponame, user=username, namespace=namespace)
+        session, reponame, user=username, namespace=namespace)
     if not repo:
         raise pagure.exceptions.PagureException(
             'Unknown repo %s of username: %s in namespace: %s' % (
@@ -882,7 +882,8 @@ def add_file_to_git(repo, issue, ticketfolder, user, filename, filestream):
             'refs/heads/master',
             author,
             author,
-            'Add file %s to ticket %s: %s' % (filename, issue.uid, issue.title),
+            'Add file %s to ticket %s: %s' % (
+                filename, issue.uid, issue.title),
             new_repo.index.write_tree(),
             parents)
         index.write()
@@ -1484,7 +1485,6 @@ def diff_pull_request(
 
     """
 
-    commitid = None
     diff = None
     diff_commits = []
     diff, diff_commits, _ = get_diff_info(
@@ -1647,6 +1647,6 @@ def reinit_git(project, repofolder):
 
     # create it again
     pygit2.init_repository(
-            repo_path, bare=True,
-            mode=pygit2.C.GIT_REPOSITORY_INIT_SHARED_GROUP
+        repo_path, bare=True,
+        mode=pygit2.C.GIT_REPOSITORY_INIT_SHARED_GROUP
     )
diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index c60bb90..7530d70 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -909,8 +909,10 @@ class DeployKey(BASE):
     project = relation(
         'Project', foreign_keys=[project_id], remote_side=[Project.id],
         backref=backref(
-            'deploykeys', cascade="delete, delete-orphan", single_parent=True)
+            'deploykeys', cascade="delete, delete-orphan",
+            single_parent=True
         )
+    )
 
     creator_user = relation(
         'User',
@@ -1060,8 +1062,9 @@ class Issue(BASE):
                         attachments.append(
                             (link, filename, display_name,
                              comment.date_created.strftime(
-                                '%Y-%m-%d %H:%M:%S'),
-                             str(comment.id)))
+                                 '%Y-%m-%d %H:%M:%S'),
+                             str(comment.id))
+                        )
         return attachments
 
     @property
@@ -1286,8 +1289,10 @@ class IssueKeys(BASE):
     project = relation(
         'Project', foreign_keys=[project_id], remote_side=[Project.id],
         backref=backref(
-            'issue_keys', cascade="delete, delete-orphan", single_parent=True)
+            'issue_keys', cascade="delete, delete-orphan",
+            single_parent=True
         )
+    )
 
     @property
     def data(self):
@@ -1333,8 +1338,9 @@ class IssueValues(BASE):
         backref=backref(
             'other_fields',
             cascade="delete, delete-orphan",
-            single_parent=True)
+            single_parent=True
         )
+    )
 
     key = relation(
         'IssueKeys', foreign_keys=[key_id], remote_side=[IssueKeys.id],
@@ -1381,8 +1387,9 @@ class TagIssue(BASE):
     issue = relation(
         'Issue', foreign_keys=[issue_uid], remote_side=[Issue.uid],
         backref=backref(
-            'old_tags', cascade="delete, delete-orphan", single_parent=True)
+            'old_tags', cascade="delete, delete-orphan", single_parent=True
         )
+    )
 
     def __repr__(self):
         return 'TagIssue(issue:%s, tag:%s)' % (self.issue.id, self.tag)
@@ -1489,8 +1496,9 @@ class TagProject(BASE):
     project = relation(
         'Project', foreign_keys=[project_id], remote_side=[Project.id],
         backref=backref(
-            'tags', cascade="delete, delete-orphan", single_parent=True)
+            'tags', cascade="delete, delete-orphan", single_parent=True
         )
+    )
 
     def __repr__(self):
         return 'TagProject(project:%s, tag:%s)' % (

From 65985dbd5f8427661ceacfbc7c93f3733af2a02b Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:52:31 +0000
Subject: [PATCH 6/18] flake8 fixes to pagure.ui


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/ui/app.py b/pagure/ui/app.py
index aa10da2..2fded03 100644
--- a/pagure/ui/app.py
+++ b/pagure/ui/app.py
@@ -262,7 +262,6 @@ def view_projects(pattern=None, namespace=None):
         SESSION, pattern=pattern, namespace=namespace,
         fork=forks, start=start, limit=limit, private=private)
 
-
     if len(projects) == 1:
         flask.flash('Only one result found, redirecting you to it')
         return flask.redirect(flask.url_for(

From c24ef82f36bcac89937974e6b5a6eb35fa79b9cc Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:53:56 +0000
Subject: [PATCH 7/18] Flake8 fixes to pagure


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/__init__.py b/pagure/__init__.py
index 4d975d3..ee0e4e0 100644
--- a/pagure/__init__.py
+++ b/pagure/__init__.py
@@ -10,40 +10,40 @@
 
 # These two lines are needed to run on EL6
 __requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
-import pkg_resources
+import pkg_resources  # noqa
 
 __version__ = '2.14.2'
 __api_version__ = '0.12'
 
 
-import datetime
-import logging
-import os
-import re
-import subprocess
-import urlparse
-from logging.handlers import SMTPHandler
+import datetime  # noqa
+import logging  # noqa
+import os  # noqa
+import re  # noqa
+import subprocess  # noqa
+import urlparse  # noqa
+from logging.handlers import SMTPHandler  # noqa
 
-import flask
-import pygit2
-import werkzeug
-from functools import wraps
-from sqlalchemy.exc import SQLAlchemyError
+import flask  # noqa
+import pygit2  # noqa
+import werkzeug  # noqa
+from functools import wraps  # noqa
+from sqlalchemy.exc import SQLAlchemyError  # noqa
 
-from pygments import highlight
-from pygments.lexers.text import DiffLexer
-from pygments.formatters import HtmlFormatter
+from pygments import highlight  # noqa
+from pygments.lexers.text import DiffLexer  # noqa
+from pygments.formatters import HtmlFormatter  # noqa
 
-from flask_multistatic import MultiStaticFlask
+from flask_multistatic import MultiStaticFlask  # noqa
 
-from werkzeug.routing import BaseConverter
+from werkzeug.routing import BaseConverter  # noqa
 
 if os.environ.get('PAGURE_PERFREPO'):
-    import pagure.perfrepo as perfrepo
+    import pagure.perfrepo as perfrepo  # noqa
 else:
     perfrepo = None
 
-import pagure.exceptions
+import pagure.exceptions  # noqa
 
 # Create the application.
 APP = MultiStaticFlask(__name__)
@@ -93,13 +93,13 @@ if APP.config.get('THEME_STATIC_FOLDER', False):
     ]
 
 
-import pagure.doc_utils
-import pagure.forms
-import pagure.lib
-import pagure.lib.git
-import pagure.login_forms
-import pagure.mail_logging
-import pagure.proxy
+import pagure.doc_utils  # noqa
+import pagure.forms  # noqa
+import pagure.lib  # noqa
+import pagure.lib.git  # noqa
+import pagure.login_forms  # noqa
+import pagure.mail_logging  # noqa
+import pagure.proxy  # noqa
 
 # Only import flask_fas_openid if it is needed
 if APP.config.get('PAGURE_AUTH', None) in ['fas', 'openid']:
@@ -426,9 +426,10 @@ def login_required(function):
             return flask.redirect(
                 flask.url_for('auth_login', next=flask.request.url))
         elif auth_method == 'fas' and not flask.g.fas_user.cla_done:
-            flask.flash(flask.Markup('You must <a href="https://admin.fedoraproject'
-                        '.org/accounts/">sign the FPCA</a> (Fedora Project '
-                        'Contributor Agreement) to use pagure'), 'errors')
+            flask.flash(flask.Markup(
+                'You must <a href="https://admin.fedoraproject'
+                '.org/accounts/">sign the FPCA</a> (Fedora Project '
+                'Contributor Agreement) to use pagure'), 'errors')
             return flask.redirect(flask.url_for('.index'))
         return function(*args, **kwargs)
     return decorated_function
@@ -504,12 +505,12 @@ def set_variables():
             SESSION, repo, user=username, namespace=namespace)
         if authenticated():
             flask.g.repo_forked = pagure.get_authorized_project(
-                    SESSION, repo, user=flask.g.fas_user.username,
-                    namespace=namespace)
+                SESSION, repo, user=flask.g.fas_user.username,
+                namespace=namespace)
 
         if not flask.g.repo \
-            and APP.config.get('OLD_VIEW_COMMIT_ENABLED', False) \
-            and len(repo) == 40:
+                and APP.config.get('OLD_VIEW_COMMIT_ENABLED', False) \
+                and len(repo) == 40:
             return flask.redirect(flask.url_for(
                 'view_commit', repo=namespace, commitid=repo,
                 username=username, namespace=None))
@@ -726,29 +727,31 @@ ip_middle_octet = u"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5]))"
 ip_last_octet = u"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
 
 """
-regex based on https://github.com/kvesteri/validators/blob/master/validators/url.py
+regex based on https://github.com/kvesteri/validators/blob/
+master/validators/url.py
 LICENSED on Dec 16th 2016 as MIT:
 
 The MIT License (MIT)
 
 Copyright (c) 2013-2014 Konsta Vesterinen
 
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
 
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
 
 """
 urlregex = re.compile(
@@ -792,18 +795,18 @@ urlregex = re.compile(
 urlpattern = re.compile(urlregex)
 
 # Import the application
-import pagure.ui.app
-import pagure.ui.fork
-import pagure.ui.groups
+import pagure.ui.app  # noqa
+import pagure.ui.fork  # noqa
+import pagure.ui.groups  # noqa
 if APP.config.get('ENABLE_TICKETS', True):
-    import pagure.ui.issues
-import pagure.ui.plugins
-import pagure.ui.repo
+    import pagure.ui.issues  # noqa
+import pagure.ui.plugins  # noqa
+import pagure.ui.repo  # noqa
 
-from pagure.api import API
+from pagure.api import API  # noqa
 APP.register_blueprint(API)
 
-import pagure.internal
+import pagure.internal  # noqa
 APP.register_blueprint(pagure.internal.PV)
 
 
diff --git a/pagure/doc_utils.py b/pagure/doc_utils.py
index 99c3099..0145a80 100644
--- a/pagure/doc_utils.py
+++ b/pagure/doc_utils.py
@@ -14,7 +14,6 @@ import docutils.core
 import docutils.examples
 import kitchen.text.converters as ktc
 import markupsafe
-import markdown
 import textwrap
 
 import pagure.lib
diff --git a/pagure/docs_server.py b/pagure/docs_server.py
index d1f9cc1..136a52f 100644
--- a/pagure/docs_server.py
+++ b/pagure/docs_server.py
@@ -140,8 +140,8 @@ def view_docs(repo, username=None, namespace=None, filename=None):
     if '.' in repo:
         namespace, repo = repo.split('.', 1)
 
-    repo = pagure.get_authorized_project(SESSION, repo, user=username,
-            namespace=namespace)
+    repo = pagure.get_authorized_project(
+        SESSION, repo, user=username, namespace=namespace)
 
     if not repo:
         flask.abort(404, 'Project not found')
@@ -162,11 +162,11 @@ def view_docs(repo, username=None, namespace=None, filename=None):
             404,
             flask.Markup(
                 'No content found is the repository, you may want to read '
-                'the <a href="https://docs.pagure.org/pagure/usage/using_doc.html">'
+                'the <a href="'
+                'https://docs.pagure.org/pagure/usage/using_doc.html">'
                 'Using the doc repository of your project</a> documentation'
             )
         )
-    branchname = 'master'
 
     content = None
     tree = None
diff --git a/pagure/forms.py b/pagure/forms.py
index 2f27c05..414ae0e 100644
--- a/pagure/forms.py
+++ b/pagure/forms.py
@@ -14,7 +14,6 @@
 
 import datetime
 import re
-import tempfile
 
 import flask
 import flask_wtf as wtf
@@ -41,7 +40,7 @@ class PagureForm(FlaskForm):
     def __init__(self, *args, **kwargs):
         delta = pagure.APP.config.get('WTF_CSRF_TIME_LIMIT', 3600)
         if delta \
-                and (not hasattr(wtf, '__version__') \
+                and (not hasattr(wtf, '__version__')
                 or tuple(
                     int(v) for v in wtf.__version__.split('.')
                 ) < (0, 10, 0)):
@@ -65,7 +64,6 @@ class MultipleEmail(wtforms.validators.Email):
     of wtforms.
     """
     def __call__(self, form, field):
-        regex = re.compile(r'^.+@[^.].*\.[a-z]{2,10}$', re.IGNORECASE)
         message = field.gettext('One or more invalid email address.')
         for data in field.data.split(','):
             data = data.strip()
diff --git a/pagure/login_forms.py b/pagure/login_forms.py
index f1c2e79..7502266 100644
--- a/pagure/login_forms.py
+++ b/pagure/login_forms.py
@@ -26,8 +26,6 @@ try:
 except ImportError:
     from flask_wtf import Form as FlaskForm
 
-from pagure.forms import ConfirmationForm
-
 
 def same_password(form, field):
     ''' Check if the data in the field is the same as in the password field.
diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py
index aa86f4e..8e791bf 100644
--- a/pagure/pfmarkdown.py
+++ b/pagure/pfmarkdown.py
@@ -19,8 +19,6 @@ Author: Ralph Bean <rbean@redhat.com>
         Pierre-Yves Chibon <pingou@pingoured.fr>
 """
 
-import re
-
 import flask
 
 import markdown.inlinepatterns
@@ -39,18 +37,20 @@ MENTION_RE = r'@(\w+)'
 #  4) See if we have a `namespace/`
 #  5) Get the last part `project`
 #  6) Get the identifier `#<id>`
-EXPLICIT_LINK_RE = r'(?<!\w)'\
-'(fork[s]?/)?'\
-'([a-zA-Z0-9_-]*?/)?'\
-'([a-zA-Z0-9_-]*?/)?'\
-'([a-zA-Z0-9_-]+)'\
-'#(?P<id>[0-9]+)'
-COMMIT_LINK_RE = r'(?<!\w)'\
-'(fork[s]?/)?'\
-'([a-zA-Z0-9_-]*?/)?'\
-'([a-zA-Z0-9_-]*?/)?'\
-'([a-zA-Z0-9_-]+)'\
-'#(?P<id>[\w]{40})'
+EXPLICIT_LINK_RE = \
+    r'(?<!\w)'\
+    '(fork[s]?/)?'\
+    '([a-zA-Z0-9_-]*?/)?'\
+    '([a-zA-Z0-9_-]*?/)?'\
+    '([a-zA-Z0-9_-]+)'\
+    '#(?P<id>[0-9]+)'
+COMMIT_LINK_RE = \
+    r'(?<!\w)'\
+    '(fork[s]?/)?'\
+    '([a-zA-Z0-9_-]*?/)?'\
+    '([a-zA-Z0-9_-]*?/)?'\
+    '([a-zA-Z0-9_-]+)'\
+    '#(?P<id>[\w]{40})'
 IMPLICIT_ISSUE_RE = r'[^|\w](?<!\w)#([0-9]+)'
 IMPLICIT_PR_RE = r'[^|\w](?<!\w)PR#([0-9]+)'
 IMPLICIT_COMMIT_RE = r'[^|\w](?<![>\w#])([a-f0-9]{7,40})'
@@ -110,7 +110,6 @@ class ExplicitLinkPattern(markdown.inlinepatterns.Pattern):
         if issue:
             return _obj_anchor_tag(user, namespace, repo, issue, text)
 
-
         request = _pr_exists(user, namespace, repo, idx)
         if request:
             return _obj_anchor_tag(user, namespace, repo, request, text)
@@ -368,12 +367,12 @@ def _obj_anchor_tag(user, namespace, repo, obj, text):
     if isinstance(obj, basestring):
         url = flask.url_for(
             'view_commit', username=user, namespace=namespace, repo=repo,
-             commitid=obj)
+            commitid=obj)
         title = 'Commit %s' % obj
     elif obj.isa == 'issue':
         url = flask.url_for(
             'view_issue', username=user, namespace=namespace, repo=repo,
-             issueid=obj.id)
+            issueid=obj.id)
         if obj.private:
             title = 'Private issue'
         else:

From d1f0d2b7e6873834b219f895136af88a5e5a2c8d Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:53:56 +0000
Subject: [PATCH 8/18] Some more flake8 clean up


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/default_config.py b/pagure/default_config.py
index 3456480..cfdb6d4 100644
--- a/pagure/default_config.py
+++ b/pagure/default_config.py
@@ -123,7 +123,7 @@ REMOTE_GIT_FOLDER = os.path.join(
     'remotes'
 )
 
-### Whether to enable scanning for viruses in attachments
+# Whether to enable scanning for viruses in attachments
 VIRUS_SCAN_ATTACHMENTS = False
 
 # Configuration file for gitolite
diff --git a/pagure/forms.py b/pagure/forms.py
index 414ae0e..7401501 100644
--- a/pagure/forms.py
+++ b/pagure/forms.py
@@ -40,10 +40,12 @@ class PagureForm(FlaskForm):
     def __init__(self, *args, **kwargs):
         delta = pagure.APP.config.get('WTF_CSRF_TIME_LIMIT', 3600)
         if delta \
-                and (not hasattr(wtf, '__version__')
-                or tuple(
-                    int(v) for v in wtf.__version__.split('.')
-                ) < (0, 10, 0)):
+                and (
+                    not hasattr(wtf, '__version__')
+                    or tuple(
+                        int(v) for v in wtf.__version__.split('.')
+                    ) < (0, 10, 0)
+                ):
             self.TIME_LIMIT = datetime.timedelta(seconds=delta)
         else:
             self.TIME_LIMIT = delta

From 9ea97e58789c0426c06943b0803a848c74d955d3 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:53:56 +0000
Subject: [PATCH 9/18] Final flake8 fixes


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/default_config.py b/pagure/default_config.py
index cfdb6d4..4501d19 100644
--- a/pagure/default_config.py
+++ b/pagure/default_config.py
@@ -26,8 +26,8 @@ DB_URL = 'sqlite:////var/tmp/pagure_dev.sqlite'
 INSTANCE_NAME = 'Pagure'
 
 # url to datagrepper (optional):
-#DATAGREPPER_URL = 'https://apps.fedoraproject.org/datagrepper'
-#DATAGREPPER_CATEGORY = 'pagure'
+# DATAGREPPER_URL = 'https://apps.fedoraproject.org/datagrepper'
+# DATAGREPPER_CATEGORY = 'pagure'
 
 # The FAS group in which the admin of pagure are
 ADMIN_GROUP = 'sysadmin-main'
@@ -152,7 +152,7 @@ GL_RC = None
 GL_BINDIR = None
 
 
-#SMTP settings
+# SMTP settings
 SMTP_SERVER = 'localhost'
 SMTP_PORT = 25
 SMTP_SSL = False

From bd1fbf0239914cd248bfad054734ee92773ffc73 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 11:53:56 +0000
Subject: [PATCH 10/18] Add a test enforcing the flake8 compliance


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/tests/test_style.py b/tests/test_style.py
new file mode 100644
index 0000000..74c1333
--- /dev/null
+++ b/tests/test_style.py
@@ -0,0 +1,24 @@
+import os
+import subprocess
+import unittest
+
+
+REPO_PATH = os.path.abspath(
+    os.path.join(os.path.dirname(__file__), '..', 'pagure'))
+
+
+class TestStyle(unittest.TestCase):
+    """This test class contains tests pertaining to code style."""
+    def test_code_with_flake8(self):
+        """Enforce PEP-8 compliance on the codebase.
+
+        This test runs flake8 on the code, and will fail if it returns a non-zero exit code.
+        """
+        # We ignore E712, which disallows non-identity comparisons with True and False
+        flake8_command = ['flake8', '--ignore=E712,W503', REPO_PATH]
+
+        self.assertEqual(subprocess.call(flake8_command), 0)
+
+
+if __name__ == '__main__':
+    unittest.main(verbosity=2)

From 2fefaf8de964c7ad9d6e4f3e8ad61f067c43d7c0 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 12:56:19 +0000
Subject: [PATCH 11/18] List flake8 in the requirements for the tests


---

diff --git a/tests_requirements.txt b/tests_requirements.txt
index 1f20f05..7941d88 100644
--- a/tests_requirements.txt
+++ b/tests_requirements.txt
@@ -1,6 +1,7 @@
 mock==1.1.2
 nose
 nosexcover
+flake8
 
 # Seems that mock doesn't list this one
 funcsigs

From 79825bdba5a26713468c37ffda9a0b2ca9780036 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 13:23:48 +0000
Subject: [PATCH 12/18] Small pep8 fix to make the test suite happy on jenkins


---

diff --git a/pagure/perfrepo.py b/pagure/perfrepo.py
index 1db4745..900adc1 100644
--- a/pagure/perfrepo.py
+++ b/pagure/perfrepo.py
@@ -190,6 +190,7 @@ class PerfRepo(object):
         TOTALS['steps'] += 1
         return self.iter.next()
 
+
 pygit2.Repository = PerfRepo
 
 

From a345376fd11da3a7f127ef9a607d655222a8b8d8 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 13:47:16 +0000
Subject: [PATCH 13/18] And another pep8 fix to make the test suite happy on jenkins


---

diff --git a/pagure/perfrepo.py b/pagure/perfrepo.py
index 900adc1..ca0b54d 100644
--- a/pagure/perfrepo.py
+++ b/pagure/perfrepo.py
@@ -204,6 +204,7 @@ def reset_stats():
                           'diffs': 0,
                           'inits': 0}}
 
+
 # Make sure we start blank
 reset_stats()
 

From de6f12718e62b7715eee293af0ba943471660502 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 14:08:28 +0000
Subject: [PATCH 14/18] Be explicit about which error to ignore on imports


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/ev-server/pagure_stream_server.py b/ev-server/pagure_stream_server.py
index 0d74f1d..d2ed404 100644
--- a/ev-server/pagure_stream_server.py
+++ b/ev-server/pagure_stream_server.py
@@ -35,9 +35,9 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.lib  # noqa
-from pagure.exceptions import PagureEvException  # noqa
+import pagure  # noqa: E402
+import pagure.lib  # noqa: E402
+from pagure.exceptions import PagureEvException  # noqa: E402
 
 SERVER = None
 
diff --git a/pagure/__init__.py b/pagure/__init__.py
index ee0e4e0..6a9b417 100644
--- a/pagure/__init__.py
+++ b/pagure/__init__.py
@@ -10,40 +10,40 @@
 
 # These two lines are needed to run on EL6
 __requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
-import pkg_resources  # noqa
+import pkg_resources  # noqa: E402
 
 __version__ = '2.14.2'
 __api_version__ = '0.12'
 
 
-import datetime  # noqa
-import logging  # noqa
-import os  # noqa
-import re  # noqa
-import subprocess  # noqa
-import urlparse  # noqa
-from logging.handlers import SMTPHandler  # noqa
+import datetime  # noqa: E402
+import logging  # noqa: E402
+import os  # noqa: E402
+import re  # noqa: E402
+import subprocess  # noqa: E402
+import urlparse  # noqa: E402
+from logging.handlers import SMTPHandler  # noqa: E402
 
-import flask  # noqa
-import pygit2  # noqa
-import werkzeug  # noqa
-from functools import wraps  # noqa
-from sqlalchemy.exc import SQLAlchemyError  # noqa
+import flask  # noqa: E402
+import pygit2  # noqa: E402
+import werkzeug  # noqa: E402
+from functools import wraps  # noqa: E402
+from sqlalchemy.exc import SQLAlchemyError  # noqa: E402
 
-from pygments import highlight  # noqa
-from pygments.lexers.text import DiffLexer  # noqa
-from pygments.formatters import HtmlFormatter  # noqa
+from pygments import highlight  # noqa: E402
+from pygments.lexers.text import DiffLexer  # noqa: E402
+from pygments.formatters import HtmlFormatter  # noqa: E402
 
-from flask_multistatic import MultiStaticFlask  # noqa
+from flask_multistatic import MultiStaticFlask  # noqa: E402
 
-from werkzeug.routing import BaseConverter  # noqa
+from werkzeug.routing import BaseConverter  # noqa: E402
 
 if os.environ.get('PAGURE_PERFREPO'):
-    import pagure.perfrepo as perfrepo  # noqa
+    import pagure.perfrepo as perfrepo  # noqa: E402
 else:
     perfrepo = None
 
-import pagure.exceptions  # noqa
+import pagure.exceptions  # noqa: E402
 
 # Create the application.
 APP = MultiStaticFlask(__name__)
@@ -93,13 +93,13 @@ if APP.config.get('THEME_STATIC_FOLDER', False):
     ]
 
 
-import pagure.doc_utils  # noqa
-import pagure.forms  # noqa
-import pagure.lib  # noqa
-import pagure.lib.git  # noqa
-import pagure.login_forms  # noqa
-import pagure.mail_logging  # noqa
-import pagure.proxy  # noqa
+import pagure.doc_utils  # noqa: E402
+import pagure.forms  # noqa: E402
+import pagure.lib  # noqa: E402
+import pagure.lib.git  # noqa: E402
+import pagure.login_forms  # noqa: E402
+import pagure.mail_logging  # noqa: E402
+import pagure.proxy  # noqa: E402
 
 # Only import flask_fas_openid if it is needed
 if APP.config.get('PAGURE_AUTH', None) in ['fas', 'openid']:
@@ -795,18 +795,18 @@ urlregex = re.compile(
 urlpattern = re.compile(urlregex)
 
 # Import the application
-import pagure.ui.app  # noqa
-import pagure.ui.fork  # noqa
-import pagure.ui.groups  # noqa
+import pagure.ui.app  # noqa: E402
+import pagure.ui.fork  # noqa: E402
+import pagure.ui.groups  # noqa: E402
 if APP.config.get('ENABLE_TICKETS', True):
-    import pagure.ui.issues  # noqa
-import pagure.ui.plugins  # noqa
-import pagure.ui.repo  # noqa
+    import pagure.ui.issues  # noqa: E402
+import pagure.ui.plugins  # noqa: E402
+import pagure.ui.repo  # noqa: E402
 
-from pagure.api import API  # noqa
+from pagure.api import API  # noqa: E402
 APP.register_blueprint(API)
 
-import pagure.internal  # noqa
+import pagure.internal  # noqa: E402
 APP.register_blueprint(pagure.internal.PV)
 
 
diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py
index 6482699..c3c22aa 100644
--- a/pagure/api/__init__.py
+++ b/pagure/api/__init__.py
@@ -26,11 +26,11 @@ import markupsafe
 API = flask.Blueprint('api_ns', __name__, url_prefix='/api/0')
 
 
-import pagure  # noqa
-import pagure.lib  # noqa
-from pagure import __api_version__, APP, SESSION, authenticated  # noqa
-from pagure.doc_utils import load_doc, modify_rst, modify_html  # noqa
-from pagure.exceptions import APIError  # noqa
+import pagure  # noqa: E402
+import pagure.lib  # noqa: E402
+from pagure import __api_version__, APP, SESSION, authenticated  # noqa: E402
+from pagure.doc_utils import load_doc, modify_rst, modify_html  # noqa: E402
+from pagure.exceptions import APIError  # noqa: E402
 
 
 def preload_docs(endpoint):
@@ -209,14 +209,14 @@ def api_method(function):
 
 
 if pagure.APP.config.get('ENABLE_TICKETS', True):
-    from pagure.api import issue  # noqa
-from pagure.api import fork  # noqa
-from pagure.api import project  # noqa
-from pagure.api import user  # noqa
-from pagure.api import group  # noqa
+    from pagure.api import issue  # noqa: E402
+from pagure.api import fork  # noqa: E402
+from pagure.api import project  # noqa: E402
+from pagure.api import user  # noqa: E402
+from pagure.api import group  # noqa: E402
 
 if pagure.APP.config.get('PAGURE_CI_SERVICES', False):
-    from pagure.api.ci import jenkins  # noqa
+    from pagure.api.ci import jenkins  # noqa: E402
 
 
 @API.route('/version/')
diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py
index ee95bcc..cc840ca 100644
--- a/pagure/cli/admin.py
+++ b/pagure/cli/admin.py
@@ -20,10 +20,10 @@ if 'PAGURE_CONFIG' not in os.environ \
     print('Using configuration file `/etc/pagure/pagure.cfg`')
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
-import pagure.exceptions  # noqa
-import pagure.lib  # noqa
-import pagure.lib.git  # noqa
-from pagure import (SESSION, APP, generate_user_key_files)  # noqa
+import pagure.exceptions  # noqa: E402
+import pagure.lib  # noqa: E402
+import pagure.lib.git  # noqa: E402
+from pagure import (SESSION, APP, generate_user_key_files)  # noqa: E402
 
 
 _log = logging.getLogger(__name__)
diff --git a/pagure/hooks/files/default_hook.py b/pagure/hooks/files/default_hook.py
index 36cb3f4..790d8d6 100755
--- a/pagure/hooks/files/default_hook.py
+++ b/pagure/hooks/files/default_hook.py
@@ -18,11 +18,11 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.exceptions  # noqa
-import pagure.lib.link  # noqa
+import pagure  # noqa: E402
+import pagure.exceptions  # noqa: E402
+import pagure.lib.link  # noqa: E402
 
-from pagure.lib import REDIS  # noqa
+from pagure.lib import REDIS  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/fedmsg_hook.py b/pagure/hooks/files/fedmsg_hook.py
index b8a6052..c20220f 100755
--- a/pagure/hooks/files/fedmsg_hook.py
+++ b/pagure/hooks/files/fedmsg_hook.py
@@ -12,8 +12,8 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.lib.git  # noqa
+import pagure  # noqa: E402
+import pagure.lib.git  # noqa: E402
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
 
diff --git a/pagure/hooks/files/pagure_block_unsigned.py b/pagure/hooks/files/pagure_block_unsigned.py
index deb9d5a..865c309 100755
--- a/pagure/hooks/files/pagure_block_unsigned.py
+++ b/pagure/hooks/files/pagure_block_unsigned.py
@@ -14,10 +14,10 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.exceptions  # noqa
-import pagure.lib.link  # noqa
-import pagure.ui.plugins  # noqa
+import pagure  # noqa: E402
+import pagure.exceptions  # noqa: E402
+import pagure.lib.link  # noqa: E402
+import pagure.ui.plugins  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_force_commit_hook.py b/pagure/hooks/files/pagure_force_commit_hook.py
index ac6f9f6..d06971d 100755
--- a/pagure/hooks/files/pagure_force_commit_hook.py
+++ b/pagure/hooks/files/pagure_force_commit_hook.py
@@ -13,10 +13,10 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.exceptions  # noqa
-import pagure.lib.link  # noqa
-import pagure.lib.plugins  # noqa
+import pagure  # noqa: E402
+import pagure.exceptions  # noqa: E402
+import pagure.lib.link  # noqa: E402
+import pagure.lib.plugins  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_hook.py b/pagure/hooks/files/pagure_hook.py
index 115db53..d88bdd5 100755
--- a/pagure/hooks/files/pagure_hook.py
+++ b/pagure/hooks/files/pagure_hook.py
@@ -17,9 +17,9 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.exceptions  # noqa
-import pagure.lib.link  # noqa
+import pagure  # noqa: E402
+import pagure.exceptions  # noqa: E402
+import pagure.lib.link  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_hook_requests.py b/pagure/hooks/files/pagure_hook_requests.py
index f9b1237..31cc5a1 100755
--- a/pagure/hooks/files/pagure_hook_requests.py
+++ b/pagure/hooks/files/pagure_hook_requests.py
@@ -16,7 +16,7 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure.lib.git  # noqa
+import pagure.lib.git  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_hook_tickets.py b/pagure/hooks/files/pagure_hook_tickets.py
index 2233851..4c5fac5 100755
--- a/pagure/hooks/files/pagure_hook_tickets.py
+++ b/pagure/hooks/files/pagure_hook_tickets.py
@@ -16,10 +16,10 @@ if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
-import pagure  # noqa
-import pagure.lib.git  # noqa
+import pagure  # noqa: E402
+import pagure.lib.git  # noqa: E402
 
-from pagure.lib import REDIS  # noqa
+from pagure.lib import REDIS  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/rtd_hook.py b/pagure/hooks/files/rtd_hook.py
index fa6dcb1..56c3dca 100755
--- a/pagure/hooks/files/rtd_hook.py
+++ b/pagure/hooks/files/rtd_hook.py
@@ -15,10 +15,10 @@ if 'PAGURE_CONFIG' not in os.environ \
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
-import pagure  # noqa
-import pagure.exceptions  # noqa
-import pagure.lib.link  # noqa
-import pagure.lib.plugins  # noqa
+import pagure  # noqa: E402
+import pagure.exceptions  # noqa: E402
+import pagure.lib.link  # noqa: E402
+import pagure.lib.plugins  # noqa: E402
 
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py
index 11b0df2..2cbaad2 100644
--- a/pagure/internal/__init__.py
+++ b/pagure/internal/__init__.py
@@ -20,13 +20,13 @@ from sqlalchemy.exc import SQLAlchemyError
 
 PV = flask.Blueprint('internal_ns', __name__, url_prefix='/pv')
 
-import pagure  # noqa
-import pagure.exceptions  # noqa
-import pagure.forms  # noqa
-import pagure.lib  # noqa
-import pagure.lib.git  # noqa
-import pagure.ui.fork  # noqa
-from pagure import is_repo_admin, authenticated  # noqa
+import pagure  # noqa: E402
+import pagure.exceptions  # noqa: E402
+import pagure.forms  # noqa: E402
+import pagure.lib  # noqa: E402
+import pagure.lib.git  # noqa: E402
+import pagure.ui.fork  # noqa: E402
+from pagure import is_repo_admin, authenticated  # noqa: E402
 
 
 MERGE_OPTIONS = {
diff --git a/pagure/lib/lib_ci.py b/pagure/lib/lib_ci.py
index 5f53107..e33b809 100644
--- a/pagure/lib/lib_ci.py
+++ b/pagure/lib/lib_ci.py
@@ -17,7 +17,7 @@ import pagure.lib
 
 # This import is needed as pagure.lib relies on Project.ci_hook to be
 # defined and accessible and this happens in pagure.hooks.pagure_ci
-from pagure.hooks import pagure_ci  # noqa
+from pagure.hooks import pagure_ci  # noqa: E402
 
 
 BUILD_STATS = {
diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index 7530d70..b551c53 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -9,7 +9,7 @@
 """
 
 __requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']  # noqa
-import pkg_resources  # noqa
+import pkg_resources  # noqa: E402
 
 import datetime
 import collections

From 9c193f6d014cecafd2898e5d16ace21c617f7837 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 14:11:12 +0000
Subject: [PATCH 15/18] Be explicit about which error to ignore


Ignore E402 on imports and E501 on a docstring that uses long URLs

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/api/issue.py b/pagure/api/issue.py
index 1497c75..58f934e 100644
--- a/pagure/api/issue.py
+++ b/pagure/api/issue.py
@@ -580,7 +580,7 @@ def api_view_issue_comment(
           }
         }
 
-    """  # noqa
+    """  # noqa: E501
 
     repo = _get_repo(repo, username, namespace)
     _check_issue_tracker(repo)

From f30dd368631ad0d243e9dbe7f4b84702fe6cf7aa Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 15:18:48 +0000
Subject: [PATCH 16/18] Drop un-used imports, thanks jenkins


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/__init__.py b/pagure/__init__.py
index 6a9b417..54b97b3 100644
--- a/pagure/__init__.py
+++ b/pagure/__init__.py
@@ -20,9 +20,7 @@ import datetime  # noqa: E402
 import logging  # noqa: E402
 import os  # noqa: E402
 import re  # noqa: E402
-import subprocess  # noqa: E402
 import urlparse  # noqa: E402
-from logging.handlers import SMTPHandler  # noqa: E402
 
 import flask  # noqa: E402
 import pygit2  # noqa: E402
@@ -30,14 +28,8 @@ import werkzeug  # noqa: E402
 from functools import wraps  # noqa: E402
 from sqlalchemy.exc import SQLAlchemyError  # noqa: E402
 
-from pygments import highlight  # noqa: E402
-from pygments.lexers.text import DiffLexer  # noqa: E402
-from pygments.formatters import HtmlFormatter  # noqa: E402
-
 from flask_multistatic import MultiStaticFlask  # noqa: E402
 
-from werkzeug.routing import BaseConverter  # noqa: E402
-
 if os.environ.get('PAGURE_PERFREPO'):
     import pagure.perfrepo as perfrepo  # noqa: E402
 else:
diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py
index 2cbaad2..48c56ed 100644
--- a/pagure/internal/__init__.py
+++ b/pagure/internal/__init__.py
@@ -26,7 +26,6 @@ import pagure.forms  # noqa: E402
 import pagure.lib  # noqa: E402
 import pagure.lib.git  # noqa: E402
 import pagure.ui.fork  # noqa: E402
-from pagure import is_repo_admin, authenticated  # noqa: E402
 
 
 MERGE_OPTIONS = {

From 40e8fa2d55495b089eca4d8c91d68f53ac18e8db Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 15:18:59 +0000
Subject: [PATCH 17/18] Ignore some of the import that are useful although not apparently used


Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

---

diff --git a/pagure/lib/lib_ci.py b/pagure/lib/lib_ci.py
index e33b809..624adee 100644
--- a/pagure/lib/lib_ci.py
+++ b/pagure/lib/lib_ci.py
@@ -17,7 +17,7 @@ import pagure.lib
 
 # This import is needed as pagure.lib relies on Project.ci_hook to be
 # defined and accessible and this happens in pagure.hooks.pagure_ci
-from pagure.hooks import pagure_ci  # noqa: E402
+from pagure.hooks import pagure_ci  # noqa: E402,F401
 
 
 BUILD_STATS = {
diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index b551c53..5c68750 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -9,7 +9,7 @@
 """
 
 __requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']  # noqa
-import pkg_resources  # noqa: E402
+import pkg_resources  # noqa: E402,F401
 
 import datetime
 import collections

From 55a1560d7f98ce0742f88feddead347ef973bf21 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Apr 18 2017 15:53:01 +0000
Subject: [PATCH 18/18] Hopefully last flake8 fix


---

diff --git a/pagure/__init__.py b/pagure/__init__.py
index 54b97b3..fcb673c 100644
--- a/pagure/__init__.py
+++ b/pagure/__init__.py
@@ -10,7 +10,7 @@
 
 # These two lines are needed to run on EL6
 __requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
-import pkg_resources  # noqa: E402
+import pkg_resources  # noqa: E402,F401
 
 __version__ = '2.14.2'
 __api_version__ = '0.12'

