jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/378741 )

Change subject: Use isort to sort imports
......................................................................


Use isort to sort imports

isort is a Python utility to sort imports alphabetically,
and automatically separated into sections.

This adds to `setup.cfg` an isort config closely mimicking
our current conventions (cf `multi_line_output`), and
updates the entire codebase.

Change-Id: Id37f2e645db0c93951916410f0fbd34fee0b62be
---
M bin/deploy_message_from_git_log.py
M erfgoedbot/add_coord_to_articles.py
M erfgoedbot/add_object_location_monuments.py
M erfgoedbot/categorize_images.py
M erfgoedbot/checkers.py
M erfgoedbot/common.py
M erfgoedbot/converters.py
M erfgoedbot/database_connection.py
M erfgoedbot/fill_table_monuments_all.py
M erfgoedbot/images_of_monuments_without_id.py
M erfgoedbot/missing_commonscat_links.py
M erfgoedbot/monument_tables.py
M erfgoedbot/monuments_config.py
M erfgoedbot/populate_image_table.py
M erfgoedbot/unused_monument_images.py
M erfgoedbot/update_database.py
M erfgoedbot/update_id_dump.py
M requirements-test.txt
M setup.cfg
M tests/test_categorization.py
M tests/test_checkers.py
M tests/test_common.py
M tests/test_converters.py
M tests/test_database_connection.py
M tests/test_database_statistics.py
M tests/test_fill_table.py
M tests/test_monument_tables.py
M tests/test_monuments_config.py
M tests/test_populate_image_table.py
M tests/test_update_database.py
M tox.ini
31 files changed, 103 insertions(+), 58 deletions(-)

Approvals:
  Lokal Profil: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/bin/deploy_message_from_git_log.py 
b/bin/deploy_message_from_git_log.py
index fa609d4..8e6c8de 100644
--- a/bin/deploy_message_from_git_log.py
+++ b/bin/deploy_message_from_git_log.py
@@ -4,7 +4,6 @@
 import re
 import subprocess
 
-
 GIT_COMMIT_FIELDS = ['id', 'message']
 GIT_LOG_FORMAT_FIELDS = ['%h', '%b']
 GIT_LOG_FORMAT = '%x1f'.join(GIT_LOG_FORMAT_FIELDS) + '%x1e'
diff --git a/erfgoedbot/add_coord_to_articles.py 
b/erfgoedbot/add_coord_to_articles.py
index 58fa56e..3e1e963 100644
--- a/erfgoedbot/add_coord_to_articles.py
+++ b/erfgoedbot/add_coord_to_articles.py
@@ -19,12 +19,12 @@
 
 import pywikibot
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
-    connect_to_monuments_database,
-    connect_to_commons_database
+    connect_to_commons_database,
+    connect_to_monuments_database
 )
 
 # coordinate templates for different language wikipedias
diff --git a/erfgoedbot/add_object_location_monuments.py 
b/erfgoedbot/add_object_location_monuments.py
index 608df47..fe9158c 100644
--- a/erfgoedbot/add_object_location_monuments.py
+++ b/erfgoedbot/add_object_location_monuments.py
@@ -7,12 +7,12 @@
 '''
 import pywikibot
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
-    connect_to_monuments_database,
-    connect_to_commons_database
+    connect_to_commons_database,
+    connect_to_monuments_database
 )
 
 
diff --git a/erfgoedbot/categorize_images.py b/erfgoedbot/categorize_images.py
index f6df29c..f7c61e0 100644
--- a/erfgoedbot/categorize_images.py
+++ b/erfgoedbot/categorize_images.py
@@ -18,14 +18,14 @@
 '''
 import json
 import os
+
 import yaml
 
 import pywikibot
-from pywikibot import pagegenerators
-from pywikibot import textlib
+from pywikibot import pagegenerators, textlib
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
     connect_to_monuments_database
diff --git a/erfgoedbot/checkers.py b/erfgoedbot/checkers.py
index cf98240..fb31545 100644
--- a/erfgoedbot/checkers.py
+++ b/erfgoedbot/checkers.py
@@ -4,6 +4,7 @@
 """Checker methods"""
 
 import pywikibot
+
 import common as common
 
 _logger = "update_database"
diff --git a/erfgoedbot/common.py b/erfgoedbot/common.py
index 088b550..e737521 100644
--- a/erfgoedbot/common.py
+++ b/erfgoedbot/common.py
@@ -2,9 +2,11 @@
 # -*- coding: utf-8  -*-
 """Support library of commonly shared functions."""
 from __future__ import unicode_literals
-from builtins import open
+
 import os
 import re
+from builtins import open
+
 import pywikibot
 from pywikibot.exceptions import OtherPageSaveError, PageSaveRelatedError
 
diff --git a/erfgoedbot/converters.py b/erfgoedbot/converters.py
index 92abc44..6747319 100644
--- a/erfgoedbot/converters.py
+++ b/erfgoedbot/converters.py
@@ -4,6 +4,7 @@
 """Conversion methods"""
 
 import re
+
 from checkers import is_int
 
 
diff --git a/erfgoedbot/database_connection.py 
b/erfgoedbot/database_connection.py
index 741b061..1438e8a 100644
--- a/erfgoedbot/database_connection.py
+++ b/erfgoedbot/database_connection.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8  -*-
 
 import os
+
 import MySQLdb
 import yaml
 
diff --git a/erfgoedbot/fill_table_monuments_all.py 
b/erfgoedbot/fill_table_monuments_all.py
index 4193478..41d577a 100644
--- a/erfgoedbot/fill_table_monuments_all.py
+++ b/erfgoedbot/fill_table_monuments_all.py
@@ -2,9 +2,11 @@
 # -*- coding: utf-8  -*-
 """Create the fill_table_monuments_all SQL."""
 from __future__ import unicode_literals
-import os
+
 import json
+import os
 from collections import OrderedDict
+
 import pywikibot
 
 
diff --git a/erfgoedbot/images_of_monuments_without_id.py 
b/erfgoedbot/images_of_monuments_without_id.py
index 61e30cc..f4c9fa3 100644
--- a/erfgoedbot/images_of_monuments_without_id.py
+++ b/erfgoedbot/images_of_monuments_without_id.py
@@ -15,12 +15,12 @@
 '''
 import pywikibot
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
-    connect_to_monuments_database,
-    connect_to_commons_database
+    connect_to_commons_database,
+    connect_to_monuments_database
 )
 
 
diff --git a/erfgoedbot/missing_commonscat_links.py 
b/erfgoedbot/missing_commonscat_links.py
index 3f9594a..35b5569 100644
--- a/erfgoedbot/missing_commonscat_links.py
+++ b/erfgoedbot/missing_commonscat_links.py
@@ -15,12 +15,12 @@
 
 import pywikibot
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
-    connect_to_monuments_database,
-    connect_to_commons_database
+    connect_to_commons_database,
+    connect_to_monuments_database
 )
 
 _logger = "missing_commonscat"
diff --git a/erfgoedbot/monument_tables.py b/erfgoedbot/monument_tables.py
index 15bee1e..a6fd148 100755
--- a/erfgoedbot/monument_tables.py
+++ b/erfgoedbot/monument_tables.py
@@ -6,6 +6,7 @@
 Author: Platonides
 """
 import os
+
 import monuments_config as mconfig
 
 
diff --git a/erfgoedbot/monuments_config.py b/erfgoedbot/monuments_config.py
index a12c660..788dd5d 100755
--- a/erfgoedbot/monuments_config.py
+++ b/erfgoedbot/monuments_config.py
@@ -4,8 +4,8 @@
 Configuration for the monuments bot.
 
 '''
-import os
 import json
+import os
 
 
 def _get_config_dir():
diff --git a/erfgoedbot/populate_image_table.py 
b/erfgoedbot/populate_image_table.py
index c3997a7..9f6d382 100644
--- a/erfgoedbot/populate_image_table.py
+++ b/erfgoedbot/populate_image_table.py
@@ -31,12 +31,12 @@
 
 import pywikibot
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
-    connect_to_monuments_database,
-    connect_to_commons_database
+    connect_to_commons_database,
+    connect_to_monuments_database
 )
 
 
diff --git a/erfgoedbot/unused_monument_images.py 
b/erfgoedbot/unused_monument_images.py
index 440cb49..680f453 100644
--- a/erfgoedbot/unused_monument_images.py
+++ b/erfgoedbot/unused_monument_images.py
@@ -13,12 +13,12 @@
 '''
 import pywikibot
 
-import monuments_config as mconfig
 import common as common
+import monuments_config as mconfig
 from database_connection import (
     close_database_connection,
-    connect_to_monuments_database,
-    connect_to_commons_database
+    connect_to_commons_database,
+    connect_to_monuments_database
 )
 
 _logger = "unused_images"
diff --git a/erfgoedbot/update_database.py b/erfgoedbot/update_database.py
index c99d5d3..fc0fceb 100755
--- a/erfgoedbot/update_database.py
+++ b/erfgoedbot/update_database.py
@@ -11,11 +11,11 @@
 python update_database.py -countrycode:XX -langcode:YY
 
 '''
-import os
-import warnings
 import datetime
-import urlparse
+import os
 import time
+import urlparse
+import warnings
 from collections import Counter
 
 from requests.exceptions import Timeout
@@ -24,21 +24,21 @@
 import pywikibot.data.sparql
 from pywikibot import pagegenerators
 
-import monuments_config as mconfig
 import common as common
-from converters import (
-    extractWikilink,
-    extract_elements_from_template_param,
-    remove_commons_category_prefix,
-    CH1903Converter,
-    int_to_european_digits
-)
+import monuments_config as mconfig
 from checkers import (
-    checkLat,
-    checkLon,
-    check_wikidata,
     check_integer,
-    check_lat_with_lon
+    check_lat_with_lon,
+    check_wikidata,
+    checkLat,
+    checkLon
+)
+from converters import (
+    CH1903Converter,
+    extract_elements_from_template_param,
+    extractWikilink,
+    int_to_european_digits,
+    remove_commons_category_prefix
 )
 from database_connection import (
     close_database_connection,
diff --git a/erfgoedbot/update_id_dump.py b/erfgoedbot/update_id_dump.py
index d89a5c5..a593b32 100755
--- a/erfgoedbot/update_id_dump.py
+++ b/erfgoedbot/update_id_dump.py
@@ -16,9 +16,7 @@
 from pywikibot import pagegenerators
 
 import monuments_config as mconfig
-from converters import (
-    extract_elements_from_template_param
-)
+from converters import extract_elements_from_template_param
 from database_connection import (
     close_database_connection,
     connect_to_monuments_database
diff --git a/requirements-test.txt b/requirements-test.txt
index 3135dae..00a2f22 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,6 +1,7 @@
 -r requirements.txt
 
 bashate==0.5.1
+isort==4.2.15
 mock
 nose
 nose-cov
diff --git a/setup.cfg b/setup.cfg
index c66ce3d..6e52f56 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,3 +4,10 @@
 cover-erase=1
 cover-inclusive=1
 cover-package=erfgoedbot
+
+[isort]
+known_first_party = erfgoedbot
+known_third_party = mock,requests,MySQLdb,yaml
+known_pywikibot = pywikibot
+multi_line_output = 3
+sections = FUTURE,STDLIB,THIRDPARTY,PYWIKIBOT,FIRSTPARTY,LOCALFOLDER
diff --git a/tests/test_categorization.py b/tests/test_categorization.py
index cbc4dd0..49f8af9 100644
--- a/tests/test_categorization.py
+++ b/tests/test_categorization.py
@@ -3,7 +3,9 @@
 # from pywikibot.site import APISite
 # from pywikibot.exceptions import NoPage
 import unittest
+
 import mock
+
 from erfgoedbot import categorize_images
 
 
diff --git a/tests/test_checkers.py b/tests/test_checkers.py
index 5f14221..7f4db94 100644
--- a/tests/test_checkers.py
+++ b/tests/test_checkers.py
@@ -4,9 +4,10 @@
 Those that aren't checked through test_update_database
 """
 
-import mock
 import unittest
 
+import mock
+
 from erfgoedbot import checkers
 
 
diff --git a/tests/test_common.py b/tests/test_common.py
index 529d927..c552355 100644
--- a/tests/test_common.py
+++ b/tests/test_common.py
@@ -1,10 +1,13 @@
 """Unit tests for common."""
 
-import unittest
-import mock
-import tempfile
 import os
+import tempfile
+import unittest
+
+import mock
+
 import pywikibot
+
 from erfgoedbot import common
 
 
diff --git a/tests/test_converters.py b/tests/test_converters.py
index 7dee613..600022f 100644
--- a/tests/test_converters.py
+++ b/tests/test_converters.py
@@ -2,14 +2,15 @@
 """Unit tests for converters."""
 
 import unittest
+
 from erfgoedbot.converters import (
-    ucfirst,
-    extractWikilink,
+    CH1903Converter,
     extract_elements_from_template_param,
+    extractWikilink,
+    int_to_european_digits,
     remove_commons_category_prefix,
     sanitize_wikitext_string,
-    CH1903Converter,
-    int_to_european_digits
+    ucfirst
 )
 
 
diff --git a/tests/test_database_connection.py 
b/tests/test_database_connection.py
index 519d5ba..3e556cf 100644
--- a/tests/test_database_connection.py
+++ b/tests/test_database_connection.py
@@ -2,10 +2,12 @@
 
 import os
 import unittest
+
 import mock
-from erfgoedbot import database_connection
 from MySQLdb.connections import Connection
 
+from erfgoedbot import database_connection
+
 
 class TestGetDatabaseConfigFile(unittest.TestCase):
 
diff --git a/tests/test_database_statistics.py 
b/tests/test_database_statistics.py
index 95dcad7..72a2472 100644
--- a/tests/test_database_statistics.py
+++ b/tests/test_database_statistics.py
@@ -3,7 +3,9 @@
 # from pywikibot.site import APISite
 # from pywikibot.exceptions import NoPage
 import unittest
+
 import mock
+
 from erfgoedbot import database_statistics
 
 
diff --git a/tests/test_fill_table.py b/tests/test_fill_table.py
index 2cc83cf..bcc8283 100644
--- a/tests/test_fill_table.py
+++ b/tests/test_fill_table.py
@@ -1,11 +1,12 @@
 # -*- coding: utf-8  -*-
 """Validation for fill_table_monuments_all.sql with monuments_config.py."""
 
-import unittest
 import re
+import unittest
+
 from custom_assertions import CustomAssertions
-from erfgoedbot import monuments_config as config
 from erfgoedbot import fill_table_monuments_all as fill_table
+from erfgoedbot import monuments_config as config
 
 
 def isolate_dataset_entries(text):
diff --git a/tests/test_monument_tables.py b/tests/test_monument_tables.py
index 8a85ade..84ff558 100644
--- a/tests/test_monument_tables.py
+++ b/tests/test_monument_tables.py
@@ -3,6 +3,7 @@
 """Unit tests for update_database."""
 
 import unittest
+
 import mock
 
 from erfgoedbot import monument_tables
diff --git a/tests/test_monuments_config.py b/tests/test_monuments_config.py
index f8342f5..6cc2cad 100644
--- a/tests/test_monuments_config.py
+++ b/tests/test_monuments_config.py
@@ -2,6 +2,7 @@
 """Validation for monuments_config."""
 
 import unittest
+
 from custom_assertions import CustomAssertions
 from erfgoedbot import monuments_config as config
 
diff --git a/tests/test_populate_image_table.py 
b/tests/test_populate_image_table.py
index 496811b..0b55974 100644
--- a/tests/test_populate_image_table.py
+++ b/tests/test_populate_image_table.py
@@ -3,9 +3,10 @@
 
 """Unit tests for populate_image_table."""
 
-import mock
 import unittest
 
+import mock
+
 from erfgoedbot import populate_image_table
 
 
diff --git a/tests/test_update_database.py b/tests/test_update_database.py
index 63adef2..bdb97a1 100644
--- a/tests/test_update_database.py
+++ b/tests/test_update_database.py
@@ -1,10 +1,12 @@
 """Unit tests for update_database."""
 
-import mock
 import unittest
-import pywikibot
 from collections import Counter
 
+import mock
+
+import pywikibot
+
 from erfgoedbot import update_database
 
 
diff --git a/tox.ini b/tox.ini
index 3598254..2aa74a9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = yaml,flake8,bashate,py27
+envlist = yaml,flake8,bashate,isort,py27
 skipsdist=true
 
 [testenv]
@@ -26,6 +26,21 @@
         --exclude-dir node_modules \
         {toxinidir} | xargs bashate --error . --verbose --ignore=E006"
 
+[testenv:isort]
+deps = isort==4.2.15
+commands =
+    bash -c "find {toxinidir} \
+        -type d \
+            \( \
+              -path {toxinidir}/.git -o \
+              -path {toxinidir}/.tox -o \
+              -path {toxinidir}/.venv -o \
+              -path {toxinidir}/vendor -o \
+              -path {toxinidir}/node_modules \
+            \) -prune -o \
+        -name '*.py' \
+        -print | xargs isort {posargs:--check-only} --verbose"
+
 [testenv:yaml]
 deps = yamllint
 commands =

-- 
To view, visit https://gerrit.wikimedia.org/r/378741
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id37f2e645db0c93951916410f0fbd34fee0b62be
Gerrit-PatchSet: 8
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: Lokal Profil <[email protected]>
Gerrit-Reviewer: Multichill <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to