Skip to content

Commit e03209a

Browse files
committed
Fix flake lint issues
1 parent 440e161 commit e03209a

28 files changed

+191
-61
lines changed

docs/conf.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import os
3232
import datetime
33+
import elasticsearch_dsl
3334

3435
# If extensions (or modules to document with autodoc) are in another directory,
3536
# add these directories to sys.path here. If the directory is relative to the
@@ -66,9 +67,6 @@
6667
# The version info for the project you're documenting, acts as replacement for
6768
# |version| and |release|, also used in various other places throughout the
6869
# built documents.
69-
#
70-
71-
import elasticsearch_dsl
7270

7371
# The short X.Y version.
7472
version = elasticsearch_dsl.__versionstr__
@@ -204,11 +202,11 @@
204202

205203
latex_elements = {
206204
# The paper size ('letterpaper' or 'a4paper').
207-
#'papersize': 'letterpaper',
205+
# 'papersize': 'letterpaper',
208206
# The font size ('10pt', '11pt' or '12pt').
209-
#'pointsize': '10pt',
207+
# 'pointsize': '10pt',
210208
# Additional stuff for the LaTeX preamble.
211-
#'preamble': '',
209+
# 'preamble': '',
212210
}
213211

214212
# Grouping the document tree into LaTeX files. List of tuples
@@ -218,7 +216,7 @@
218216
"index",
219217
"Elasticsearch-dsl.tex",
220218
u"Elasticsearch DSL Documentation",
221-
u"Honza Král",
219+
u"Elasticsearch B.V",
222220
"manual",
223221
),
224222
]
@@ -253,7 +251,7 @@
253251
"index",
254252
"elasticsearch-dsl",
255253
u"Elasticsearch DSL Documentation",
256-
[u"Honza Král"],
254+
[u"Elasticsearch B.V"],
257255
1,
258256
)
259257
]
@@ -272,7 +270,7 @@
272270
"index",
273271
"Elasticsearch",
274272
u"Elasticsearch Documentation",
275-
u"Honza Král",
273+
u"Elasticsearch B.V",
276274
"Elasticsearch",
277275
"One line description of project.",
278276
"Miscellaneous",

elasticsearch_dsl/__init__.py

+131-3
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,147 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
from . import connections
1819
from .query import Q
1920
from .aggs import A
2021
from .function import SF
2122
from .search import Search, MultiSearch
2223
from .update_by_query import UpdateByQuery
23-
from .field import *
24+
from .field import (
25+
Binary,
26+
Boolean,
27+
Byte,
28+
Completion,
29+
CustomField,
30+
Date,
31+
DateRange,
32+
DenseVector,
33+
Double,
34+
DoubleRange,
35+
Field,
36+
Float,
37+
FloatRange,
38+
GeoPoint,
39+
GeoShape,
40+
HalfFloat,
41+
Integer,
42+
IntegerRange,
43+
Ip,
44+
IpRange,
45+
Join,
46+
Keyword,
47+
Long,
48+
LongRange,
49+
Murmur3,
50+
Nested,
51+
Object,
52+
Percolator,
53+
RangeField,
54+
RankFeature,
55+
ScaledFloat,
56+
SearchAsYouType,
57+
Short,
58+
SparseVector,
59+
Text,
60+
TokenCount,
61+
construct_field,
62+
)
2463
from .document import Document, MetaField, InnerDoc
64+
from .exceptions import (
65+
ElasticsearchDslException,
66+
IllegalOperation,
67+
UnknownDslObject,
68+
ValidationException,
69+
)
2570
from .mapping import Mapping
2671
from .index import Index, IndexTemplate
2772
from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
28-
from .faceted_search import *
29-
from .wrappers import *
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
84+
from .utils import AttrDict, AttrList, DslBase
3085

3186
VERSION = (7, 2, 0)
3287
__version__ = VERSION
3388
__versionstr__ = ".".join(map(str, VERSION))
89+
__all__ = [
90+
"A",
91+
"AttrDict",
92+
"AttrList",
93+
"Binary",
94+
"Boolean",
95+
"Byte",
96+
"Completion",
97+
"CustomField",
98+
"Date",
99+
"DateHistogramFacet",
100+
"DateRange",
101+
"DenseVector",
102+
"Document",
103+
"Double",
104+
"DoubleRange",
105+
"DslBase",
106+
"ElasticsearchDslException",
107+
"Facet",
108+
"FacetedResponse",
109+
"FacetedSearch",
110+
"Field",
111+
"Float",
112+
"FloatRange",
113+
"GeoPoint",
114+
"GeoShape",
115+
"HalfFloat",
116+
"HistogramFacet",
117+
"IllegalOperation",
118+
"Index",
119+
"IndexTemplate",
120+
"InnerDoc",
121+
"Integer",
122+
"IntegerRange",
123+
"Ip",
124+
"IpRange",
125+
"Join",
126+
"Keyword",
127+
"Long",
128+
"LongRange",
129+
"Mapping",
130+
"MetaField",
131+
"MultiSearch",
132+
"Murmur3",
133+
"Nested",
134+
"NestedFacet",
135+
"Object",
136+
"Percolator",
137+
"Q",
138+
"Range",
139+
"RangeFacet",
140+
"RangeField",
141+
"RankFeature",
142+
"SF",
143+
"ScaledFloat",
144+
"Search",
145+
"SearchAsYouType",
146+
"Short",
147+
"SparseVector",
148+
"TermsFacet",
149+
"Text",
150+
"TokenCount",
151+
"UnknownDslObject",
152+
"UpdateByQuery",
153+
"ValidationException",
154+
"analyzer",
155+
"char_filter",
156+
"connections",
157+
"construct_field",
158+
"normalizer",
159+
"token_filter",
160+
"tokenizer",
161+
]

elasticsearch_dsl/field.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def construct_field(name_or_field, **params):
6060
if isinstance(name_or_field, Field):
6161
if params:
6262
raise ValueError(
63-
"construct_field() cannot accept parameters when passing in a construct_field object."
63+
"construct_field() cannot accept parameters "
64+
"when passing in a construct_field object."
6465
)
6566
return name_or_field
6667

elasticsearch_dsl/index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ def save(self, using=None):
317317
for k in analysis[section]
318318
):
319319
raise IllegalOperation(
320-
"You cannot update analysis configuration on an open index, you need to close index %s first."
321-
% self._name
320+
"You cannot update analysis configuration on an open index, "
321+
"you need to close index %s first." % self._name
322322
)
323323

324324
# try and update the settings

elasticsearch_dsl/query.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
from itertools import chain
2424

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

2832

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

elasticsearch_dsl/response/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
from .hit import Hit, HitMeta
2121

22+
__all__ = ["Response", "AggResponse", "UpdateByQueryResponse", "Hit", "HitMeta"]
23+
2224

2325
class Response(AttrDict):
2426
def __init__(self, search, response, doc_class=None):

elasticsearch_dsl/search.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ def highlight(self, *fields, **kwargs):
603603
}
604604
}
605605
606-
If you want to have different options for different fields you can call ``highlight`` twice::
606+
If you want to have different options for different fields
607+
you can call ``highlight`` twice::
607608
608609
Search().highlight('title', fragment_size=50).highlight('body', fragment_size=100)
609610

elasticsearch_dsl/update_by_query.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def script(self, **kwargs):
110110
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html
111111
for more details.
112112
113-
Note: the API only accepts a single script, so calling the script multiple times will overwrite.
113+
Note: the API only accepts a single script, so
114+
calling the script multiple times will overwrite.
114115
115116
Example::
116117

examples/completion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Index:
8282

8383
# index some sample data
8484
for id, (name, popularity) in enumerate(
85-
[("Henri de Toulouse-Lautrec", 42), ("Jára Cimrman", 124),]
85+
[("Henri de Toulouse-Lautrec", 42), ("Jára Cimrman", 124)]
8686
):
8787
Person(_id=id, name=name, popularity=popularity).save()
8888

examples/search_as_you_type.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
"""
2020
Example ``Document`` with search_as_you_type field datatype and how to search it.
2121
22-
When creating a field with search_as_you_type datatype ElasticSearch creates additional subfields to enable efficient
23-
as-you-type completion, matching terms at any position within the input.
22+
When creating a field with search_as_you_type datatype ElasticSearch creates additional
23+
subfields to enable efficient as-you-type completion, matching terms at any position
24+
within the input.
2425
2526
To custom analyzer with ascii folding allow search to work in different languages.
2627
"""

noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def lint(session):
5151
session.install("flake8", "black")
5252

5353
session.run("black", "--target-version=py27", "--check", *SOURCE_FILES)
54-
session.run("flake8", *SOURCE_FILES)
54+
session.run("flake8", "--max-line-length=100", "--ignore=E741,W503", *SOURCE_FILES)
5555
session.run("python", "utils/license_headers.py", "check", *SOURCE_FILES)
5656

5757

test_elasticsearch_dsl/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def dummy_response():
8787
"_type": "company",
8888
"_id": "elasticsearch",
8989
"_score": 12.0,
90-
"_source": {"city": "Amsterdam", "name": "Elasticsearch",},
90+
"_source": {"city": "Amsterdam", "name": "Elasticsearch"},
9191
},
9292
{
9393
"_index": "test-index",

test_elasticsearch_dsl/test_aggs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_filter_aggregation_as_nested_agg():
185185

186186
assert {
187187
"terms": {"field": "tags"},
188-
"aggs": {"filtered": {"filter": {"term": {"f": 42}},}},
188+
"aggs": {"filtered": {"filter": {"term": {"f": 42}}}},
189189
} == a.to_dict()
190190

191191

test_elasticsearch_dsl/test_document.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_to_dict_with_meta_includes_custom_index():
306306
d = MySubDoc(title="hello")
307307
d.meta.index = "other-index"
308308

309-
assert {"_index": "other-index", "_source": {"title": "hello"},} == d.to_dict(True)
309+
assert {"_index": "other-index", "_source": {"title": "hello"}} == d.to_dict(True)
310310

311311

312312
def test_to_dict_without_skip_empty_will_include_empty_fields():

test_elasticsearch_dsl/test_faceted_search.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def test_query_is_created_properly():
4545
assert {
4646
"aggs": {
4747
"_filter_tags": {
48-
"filter": {"match_all": {},},
48+
"filter": {"match_all": {}},
4949
"aggs": {"tags": {"terms": {"field": "tags"}}},
5050
},
5151
"_filter_category": {
52-
"filter": {"match_all": {},},
52+
"filter": {"match_all": {}},
5353
"aggs": {"category": {"terms": {"field": "category.raw"}}},
5454
},
5555
},
@@ -68,11 +68,11 @@ def test_query_is_created_properly_with_sort_tuple():
6868
assert {
6969
"aggs": {
7070
"_filter_tags": {
71-
"filter": {"match_all": {},},
71+
"filter": {"match_all": {}},
7272
"aggs": {"tags": {"terms": {"field": "tags"}}},
7373
},
7474
"_filter_category": {
75-
"filter": {"match_all": {},},
75+
"filter": {"match_all": {}},
7676
"aggs": {"category": {"terms": {"field": "category.raw"}}},
7777
},
7878
},
@@ -95,7 +95,7 @@ def test_filter_is_applied_to_search_but_not_relevant_facet():
9595
"aggs": {"tags": {"terms": {"field": "tags"}}},
9696
},
9797
"_filter_category": {
98-
"filter": {"match_all": {},},
98+
"filter": {"match_all": {}},
9999
"aggs": {"category": {"terms": {"field": "category.raw"}}},
100100
},
101101
},
@@ -124,11 +124,11 @@ def test_filters_are_applied_to_search_ant_relevant_facets():
124124
assert {
125125
"aggs": {
126126
"_filter_tags": {
127-
"filter": {"terms": {"category.raw": ["elastic"]},},
127+
"filter": {"terms": {"category.raw": ["elastic"]}},
128128
"aggs": {"tags": {"terms": {"field": "tags"}}},
129129
},
130130
"_filter_category": {
131-
"filter": {"terms": {"tags": ["python", "django"]},},
131+
"filter": {"terms": {"tags": ["python", "django"]}},
132132
"aggs": {"category": {"terms": {"field": "category.raw"}}},
133133
},
134134
},

test_elasticsearch_dsl/test_field.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_field_from_dict():
8383
def test_multi_fields_are_accepted_and_parsed():
8484
f = field.construct_field(
8585
"text",
86-
fields={"raw": {"type": "keyword"}, "eng": field.Text(analyzer="english"),},
86+
fields={"raw": {"type": "keyword"}, "eng": field.Text(analyzer="english")},
8787
)
8888

8989
assert isinstance(f, field.Text)

0 commit comments

Comments
 (0)