From 45d2bfdb2e5378d0dc5fab1a8612854bf1569caa Mon Sep 17 00:00:00 2001
From: Erwan Rouchet <rouchet@teklia.com>
Date: Wed, 24 Oct 2018 14:12:09 +0000
Subject: [PATCH] Flake8 3.6.0

---
 arkindex/documents/management/commands/reindex.py | 3 ++-
 arkindex/documents/surface.py                     | 2 +-
 arkindex/documents/surface_link.py                | 6 +++---
 arkindex/documents/tests/test_edit_elementpath.py | 8 ++++----
 arkindex/images/importer.py                       | 2 +-
 tests-requirements.txt                            | 2 +-
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/arkindex/documents/management/commands/reindex.py b/arkindex/documents/management/commands/reindex.py
index 8aa199a847..313cd320c4 100644
--- a/arkindex/documents/management/commands/reindex.py
+++ b/arkindex/documents/management/commands/reindex.py
@@ -89,5 +89,6 @@ class Command(BaseCommand):
             else:
                 tasks.append(reindex_pages.si())
 
-        task = chain(*tasks).delay(async=False)
+        # Use this weird dict unpacking to prevent Flake8 W606 (async is a reserved keyword)
+        task = chain(*tasks).delay(**{'async': False})
         print("Task started with ID {}".format(task.id))
diff --git a/arkindex/documents/surface.py b/arkindex/documents/surface.py
index d34d320507..8646df6234 100644
--- a/arkindex/documents/surface.py
+++ b/arkindex/documents/surface.py
@@ -68,7 +68,7 @@ class SurfaceParser(object):
             assert coords is not None, 'Missing coords'
             polygon = [
                 (int(x), int(y))
-                for x, y in re.findall('(\d+),(\d+)', coords.get('points'))
+                for x, y in re.findall(r'(\d+),(\d+)', coords.get('points'))
             ]
 
             text_id = textRegion.get('id')
diff --git a/arkindex/documents/surface_link.py b/arkindex/documents/surface_link.py
index eb65366476..d31c0ab4b1 100644
--- a/arkindex/documents/surface_link.py
+++ b/arkindex/documents/surface_link.py
@@ -125,7 +125,7 @@ class SurfaceLinker(object):
         self.acts_raw = sorted([
             ActRaw(row[0], row[1])
             for row in data
-        ], key=lambda a: int(re.sub('[^\d+]', '', a.number)))
+        ], key=lambda a: int(re.sub(r'[^\d+]', '', a.number)))
 
     def find_pages(self):
         # TODO: support all page types !
@@ -260,7 +260,7 @@ class SurfaceLinker(object):
                 return
 
             # Get integer without complements
-            act_int = int(re.sub('[^\d]', '', act.number))
+            act_int = int(re.sub(r'[^\d]', '', act.number))
 
             # First act
             if i == 0 and act_int > 1:
@@ -270,7 +270,7 @@ class SurfaceLinker(object):
                 continue
 
             next_act = self.acts_raw[i + 1]
-            next_act_int = int(re.sub('[^\d]', '', next_act.number))
+            next_act_int = int(re.sub(r'[^\d]', '', next_act.number))
 
             # If an act seems missing (e.g. 13-15)
             if next_act_int - act_int > 1:
diff --git a/arkindex/documents/tests/test_edit_elementpath.py b/arkindex/documents/tests/test_edit_elementpath.py
index 92ff619142..994a40327c 100644
--- a/arkindex/documents/tests/test_edit_elementpath.py
+++ b/arkindex/documents/tests/test_edit_elementpath.py
@@ -69,7 +69,7 @@ class TestEditElementPath(FixtureTestCase):
         )
 
     def test_add_parent(self):
-        """
+        r"""
         Test adding A as a parent of B.
             X   Y
              \ /
@@ -157,7 +157,7 @@ class TestEditElementPath(FixtureTestCase):
         self.check_parents(elements, 'B', ['A'])
 
     def test_remove_child(self):
-        """
+        r"""
         Test removing child B from parent A.
             X   Y
              \ /
@@ -218,7 +218,7 @@ class TestEditElementPath(FixtureTestCase):
         self.check_parents(elements, 'G', ['K', 'B', 'D'])
 
     def test_remove_child_update(self):
-        """
+        r"""
         Scenario where updates are required
             X   Y
              \ /
@@ -269,7 +269,7 @@ class TestEditElementPath(FixtureTestCase):
         self.check_parents(elements, 'F', ['B', 'E'])
 
     def test_delete_element(self):
-        """
+        r"""
         Test the signal works properly and is able to remove all paths when removing an Element.
             X   Y
              \ /
diff --git a/arkindex/images/importer.py b/arkindex/images/importer.py
index 9afd4d5063..becebd330c 100644
--- a/arkindex/images/importer.py
+++ b/arkindex/images/importer.py
@@ -16,7 +16,7 @@ import fnmatch
 import uuid
 
 REGEX_INDEX = re.compile(
-    b'^(?:line_(\d+) )?(.+) \d+ ([\de\-\.]+) (\d+) (\d+) (\d+) (\d+)')
+    br'^(?:line_(\d+) )?(.+) \d+ ([\de\-\.]+) (\d+) (\d+) (\d+) (\d+)')
 
 logger = logging.getLogger(__name__)
 
diff --git a/tests-requirements.txt b/tests-requirements.txt
index c1020c3fd2..52b1884f0a 100644
--- a/tests-requirements.txt
+++ b/tests-requirements.txt
@@ -1,4 +1,4 @@
-flake8==3.5.0
+flake8==3.6.0
 tripoli
 fakeredis
 django-nose
-- 
GitLab