Skip to content

Commit 8a9c374

Browse files
authored
Add isort, rename nox session blacken->format
1 parent bcb9cf3 commit 8a9c374

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+308
-170
lines changed

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
# All configuration values have a default; values that are commented out
2929
# serve to show the default.
3030

31-
import os
3231
import datetime
32+
import os
33+
3334
import elasticsearch_dsl
3435

3536
# If extensions (or modules to document with autodoc) are in another directory,

elasticsearch_dsl/__init__.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,25 @@
1616
# under the License.
1717

1818
from . import connections
19-
from .query import Q
2019
from .aggs import A
21-
from .function import SF
22-
from .search import Search, MultiSearch
23-
from .update_by_query import UpdateByQuery
20+
from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
21+
from .document import Document, InnerDoc, MetaField
22+
from .exceptions import (
23+
ElasticsearchDslException,
24+
IllegalOperation,
25+
UnknownDslObject,
26+
ValidationException,
27+
)
28+
from .faceted_search import (
29+
DateHistogramFacet,
30+
Facet,
31+
FacetedResponse,
32+
FacetedSearch,
33+
HistogramFacet,
34+
NestedFacet,
35+
RangeFacet,
36+
TermsFacet,
37+
)
2438
from .field import (
2539
Binary,
2640
Boolean,
@@ -60,28 +74,14 @@
6074
TokenCount,
6175
construct_field,
6276
)
63-
from .document import Document, MetaField, InnerDoc
64-
from .exceptions import (
65-
ElasticsearchDslException,
66-
IllegalOperation,
67-
UnknownDslObject,
68-
ValidationException,
69-
)
70-
from .mapping import Mapping
77+
from .function import SF
7178
from .index import Index, IndexTemplate
72-
from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
73-
from .faceted_search import (
74-
DateHistogramFacet,
75-
Facet,
76-
FacetedResponse,
77-
FacetedSearch,
78-
HistogramFacet,
79-
NestedFacet,
80-
RangeFacet,
81-
TermsFacet,
82-
)
83-
from .wrappers import Range
79+
from .mapping import Mapping
80+
from .query import Q
81+
from .search import MultiSearch, Search
82+
from .update_by_query import UpdateByQuery
8483
from .utils import AttrDict, AttrList, DslBase
84+
from .wrappers import Range
8585

8686
VERSION = (7, 2, 0)
8787
__version__ = VERSION

elasticsearch_dsl/aggs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
except ImportError:
2121
import collections as collections_abc
2222

23+
from .response.aggs import AggResponse, BucketData, FieldBucketData, TopHitsData
2324
from .utils import DslBase
24-
from .response.aggs import BucketData, FieldBucketData, AggResponse, TopHitsData
2525

2626

2727
def A(name_or_agg, filter=None, **params):

elasticsearch_dsl/connections.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from six import string_types
19-
2018
from elasticsearch import Elasticsearch
19+
from six import string_types
2120

2221
from .serializer import serializer
2322

elasticsearch_dsl/faceted_search.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from datetime import timedelta, datetime
18+
from datetime import datetime, timedelta
19+
1920
from six import iteritems, itervalues
2021

21-
from .search import Search
2222
from .aggs import A
23-
from .utils import AttrDict
23+
from .query import MatchAll, Nested, Range, Terms
2424
from .response import Response
25-
from .query import Terms, Nested, Range, MatchAll
25+
from .search import Search
26+
from .utils import AttrDict
2627

2728
__all__ = [
2829
"FacetedSearch",

elasticsearch_dsl/field.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
from datetime import date, datetime
2828

2929
from dateutil import parser, tz
30-
from six import string_types, iteritems, integer_types
30+
from six import integer_types, iteritems, string_types
3131
from six.moves import map
3232

33-
from .query import Q
34-
from .utils import DslBase, AttrDict, AttrList
3533
from .exceptions import ValidationException
34+
from .query import Q
35+
from .utils import AttrDict, AttrList, DslBase
3636
from .wrappers import Range
3737

3838
unicode = type(u"")

elasticsearch_dsl/query.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222

2323
from itertools import chain
2424

25-
from .utils import DslBase
26-
from .function import ScoreFunction
27-
2825
# 'SF' looks unused but the test suite assumes it's available
2926
# from this module so others are liable to do so as well.
3027
from .function import SF # noqa: F401
28+
from .function import ScoreFunction
29+
from .utils import DslBase
3130

3231

3332
def Q(name_or_query="match_all", **params):

elasticsearch_dsl/response/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# under the License.
1717

1818
from ..utils import AttrDict, AttrList, _wrap
19-
2019
from .hit import Hit, HitMeta
2120

2221
__all__ = ["Response", "AggResponse", "UpdateByQueryResponse", "Hit", "HitMeta"]

elasticsearch_dsl/response/aggs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818
from ..utils import AttrDict, AttrList
19-
from . import Response, AggResponse
19+
from . import AggResponse, Response
2020

2121

2222
class Bucket(AggResponse):

elasticsearch_dsl/search.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
except ImportError:
2323
import collections as collections_abc
2424

25-
from six import iteritems, string_types
26-
27-
from elasticsearch.helpers import scan
2825
from elasticsearch.exceptions import TransportError
26+
from elasticsearch.helpers import scan
27+
from six import iteritems, string_types
2928

30-
from .query import Q, Bool
3129
from .aggs import A, AggBase
32-
from .utils import DslBase, AttrDict
33-
from .response import Response, Hit
3430
from .connections import get_connection
3531
from .exceptions import IllegalOperation
32+
from .query import Bool, Q
33+
from .response import Hit, Response
34+
from .utils import AttrDict, DslBase
3635

3736

3837
class QueryProxy(object):

elasticsearch_dsl/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from copy import copy
2626

27-
from six import iteritems, add_metaclass
27+
from six import add_metaclass, iteritems
2828
from six.moves import map
2929

3030
from .exceptions import UnknownDslObject, ValidationException

elasticsearch_dsl/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import operator
1919

20-
from six import string_types, iteritems
20+
from six import iteritems, string_types
2121

2222
from .utils import AttrDict
2323

examples/alias_migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from datetime import datetime
3939
from fnmatch import fnmatch
4040

41-
from elasticsearch_dsl import Document, Date, Text, Keyword, connections
41+
from elasticsearch_dsl import Date, Document, Keyword, Text, connections
4242

4343
ALIAS = "test-blog"
4444
PATTERN = ALIAS + "-*"

examples/completion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
from itertools import permutations
3232

3333
from elasticsearch_dsl import (
34-
connections,
35-
Document,
3634
Completion,
37-
Text,
38-
Long,
35+
Document,
3936
Keyword,
37+
Long,
38+
Text,
4039
analyzer,
40+
connections,
4141
token_filter,
4242
)
4343

examples/composite_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from __future__ import print_function
1919

20-
from elasticsearch_dsl import connections, Search, A
20+
from elasticsearch_dsl import A, Search, connections
2121

2222

2323
def scan_aggs(search, source_aggs, inner_aggs={}, size=10):

examples/parent_child.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
from datetime import datetime
4343

4444
from elasticsearch_dsl import (
45-
Document,
46-
Date,
47-
Text,
48-
Keyword,
4945
Boolean,
46+
Date,
47+
Document,
5048
InnerDoc,
51-
Nested,
52-
Object,
5349
Join,
50+
Keyword,
5451
Long,
52+
Nested,
53+
Object,
54+
Text,
5555
connections,
5656
)
5757

examples/percolate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
from elasticsearch_dsl import (
1919
Document,
20-
Percolator,
21-
Text,
2220
Keyword,
23-
connections,
21+
Percolator,
2422
Q,
2523
Search,
24+
Text,
25+
connections,
2626
)
2727

2828

examples/search_as_you_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
from __future__ import print_function, unicode_literals
2929

3030
from elasticsearch_dsl import (
31-
connections,
3231
Document,
32+
SearchAsYouType,
3333
analyzer,
34+
connections,
3435
token_filter,
35-
SearchAsYouType,
3636
)
3737
from elasticsearch_dsl.query import MultiMatch
3838

noxfile.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import nox
1919

20-
2120
SOURCE_FILES = (
2221
"setup.py",
2322
"noxfile.py",
@@ -37,22 +36,30 @@ def test(session):
3736

3837

3938
@nox.session()
40-
def blacken(session):
41-
session.install("black")
42-
43-
session.run("black", "--target-version=py27", *SOURCE_FILES)
44-
session.run("python", "utils/license_headers.py", "fix", *SOURCE_FILES)
39+
def format(session):
40+
session.install("black", "isort")
41+
session.run(
42+
"black", "--target-version=py27", "--target-version=py37", *SOURCE_FILES
43+
)
44+
session.run("isort", *SOURCE_FILES)
45+
session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES)
4546

4647
lint(session)
4748

4849

49-
@nox.session()
50+
@nox.session
5051
def lint(session):
51-
session.install("flake8", "black")
52-
53-
session.run("black", "--target-version=py27", "--check", *SOURCE_FILES)
54-
session.run("flake8", "--max-line-length=100", "--ignore=E741,W503", *SOURCE_FILES)
55-
session.run("python", "utils/license_headers.py", "check", *SOURCE_FILES)
52+
session.install("flake8", "black", "isort")
53+
session.run(
54+
"black",
55+
"--check",
56+
"--target-version=py27",
57+
"--target-version=py37",
58+
*SOURCE_FILES
59+
)
60+
session.run("isort", "--check", *SOURCE_FILES)
61+
session.run("flake8", "--ignore=E501,E741,W503", *SOURCE_FILES)
62+
session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES)
5663

5764

5865
@nox.session()

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ all_files = 1
55

66
[wheel]
77
universal = 1
8+
9+
[isort]
10+
profile = black

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818

19-
from os.path import join, dirname
20-
from setuptools import setup, find_packages
19+
from os.path import dirname, join
20+
21+
from setuptools import find_packages, setup
2122

2223
VERSION = (7, 2, 0)
2324
__version__ = VERSION

test_elasticsearch_dsl/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
from mock import Mock
2626
from pytest import fixture, skip
2727

28-
from elasticsearch_dsl.connections import connections, add_connection
28+
from elasticsearch_dsl.connections import add_connection, connections
29+
2930
from .test_integration.test_data import (
3031
DATA,
3132
FLAT_DATA,
3233
TEST_GIT_DATA,
33-
create_git_index,
3434
create_flat_git_index,
35+
create_git_index,
3536
)
36-
from .test_integration.test_document import PullRequest, Comment, User, History
37+
from .test_integration.test_document import Comment, History, PullRequest, User
3738

3839

3940
@fixture(scope="session")

test_elasticsearch_dsl/test_aggs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from elasticsearch_dsl import aggs, query
19-
2018
from pytest import raises
2119

20+
from elasticsearch_dsl import aggs, query
21+
2222

2323
def test_repr():
2424
max_score = aggs.Max(field="score")

0 commit comments

Comments
 (0)