Skip to content

Commit

Permalink
Fix flake lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Jul 16, 2020
1 parent 440e161 commit e03209a
Show file tree
Hide file tree
Showing 28 changed files with 191 additions and 61 deletions.
16 changes: 7 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import os
import datetime
import elasticsearch_dsl

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

import elasticsearch_dsl

# The short X.Y version.
version = elasticsearch_dsl.__versionstr__
Expand Down Expand Up @@ -204,11 +202,11 @@

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# 'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand All @@ -218,7 +216,7 @@
"index",
"Elasticsearch-dsl.tex",
u"Elasticsearch DSL Documentation",
u"Honza Král",
u"Elasticsearch B.V",
"manual",
),
]
Expand Down Expand Up @@ -253,7 +251,7 @@
"index",
"elasticsearch-dsl",
u"Elasticsearch DSL Documentation",
[u"Honza Král"],
[u"Elasticsearch B.V"],
1,
)
]
Expand All @@ -272,7 +270,7 @@
"index",
"Elasticsearch",
u"Elasticsearch Documentation",
u"Honza Král",
u"Elasticsearch B.V",
"Elasticsearch",
"One line description of project.",
"Miscellaneous",
Expand Down
134 changes: 131 additions & 3 deletions elasticsearch_dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,147 @@
# specific language governing permissions and limitations
# under the License.

from . import connections
from .query import Q
from .aggs import A
from .function import SF
from .search import Search, MultiSearch
from .update_by_query import UpdateByQuery
from .field import *
from .field import (
Binary,
Boolean,
Byte,
Completion,
CustomField,
Date,
DateRange,
DenseVector,
Double,
DoubleRange,
Field,
Float,
FloatRange,
GeoPoint,
GeoShape,
HalfFloat,
Integer,
IntegerRange,
Ip,
IpRange,
Join,
Keyword,
Long,
LongRange,
Murmur3,
Nested,
Object,
Percolator,
RangeField,
RankFeature,
ScaledFloat,
SearchAsYouType,
Short,
SparseVector,
Text,
TokenCount,
construct_field,
)
from .document import Document, MetaField, InnerDoc
from .exceptions import (
ElasticsearchDslException,
IllegalOperation,
UnknownDslObject,
ValidationException,
)
from .mapping import Mapping
from .index import Index, IndexTemplate
from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
from .faceted_search import *
from .wrappers import *
from .faceted_search import (
DateHistogramFacet,
Facet,
FacetedResponse,
FacetedSearch,
HistogramFacet,
NestedFacet,
RangeFacet,
TermsFacet,
)
from .wrappers import Range
from .utils import AttrDict, AttrList, DslBase

VERSION = (7, 2, 0)
__version__ = VERSION
__versionstr__ = ".".join(map(str, VERSION))
__all__ = [
"A",
"AttrDict",
"AttrList",
"Binary",
"Boolean",
"Byte",
"Completion",
"CustomField",
"Date",
"DateHistogramFacet",
"DateRange",
"DenseVector",
"Document",
"Double",
"DoubleRange",
"DslBase",
"ElasticsearchDslException",
"Facet",
"FacetedResponse",
"FacetedSearch",
"Field",
"Float",
"FloatRange",
"GeoPoint",
"GeoShape",
"HalfFloat",
"HistogramFacet",
"IllegalOperation",
"Index",
"IndexTemplate",
"InnerDoc",
"Integer",
"IntegerRange",
"Ip",
"IpRange",
"Join",
"Keyword",
"Long",
"LongRange",
"Mapping",
"MetaField",
"MultiSearch",
"Murmur3",
"Nested",
"NestedFacet",
"Object",
"Percolator",
"Q",
"Range",
"RangeFacet",
"RangeField",
"RankFeature",
"SF",
"ScaledFloat",
"Search",
"SearchAsYouType",
"Short",
"SparseVector",
"TermsFacet",
"Text",
"TokenCount",
"UnknownDslObject",
"UpdateByQuery",
"ValidationException",
"analyzer",
"char_filter",
"connections",
"construct_field",
"normalizer",
"token_filter",
"tokenizer",
]
3 changes: 2 additions & 1 deletion elasticsearch_dsl/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def construct_field(name_or_field, **params):
if isinstance(name_or_field, Field):
if params:
raise ValueError(
"construct_field() cannot accept parameters when passing in a construct_field object."
"construct_field() cannot accept parameters "
"when passing in a construct_field object."
)
return name_or_field

Expand Down
4 changes: 2 additions & 2 deletions elasticsearch_dsl/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ def save(self, using=None):
for k in analysis[section]
):
raise IllegalOperation(
"You cannot update analysis configuration on an open index, you need to close index %s first."
% self._name
"You cannot update analysis configuration on an open index, "
"you need to close index %s first." % self._name
)

# try and update the settings
Expand Down
6 changes: 5 additions & 1 deletion elasticsearch_dsl/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
from itertools import chain

from .utils import DslBase
from .function import SF, ScoreFunction
from .function import ScoreFunction

# 'SF' looks unused but the test suite assumes it's available
# from this module so others are liable to do so as well.
from .function import SF # noqa: F401


def Q(name_or_query="match_all", **params):
Expand Down
2 changes: 2 additions & 0 deletions elasticsearch_dsl/response/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from .hit import Hit, HitMeta

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


class Response(AttrDict):
def __init__(self, search, response, doc_class=None):
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch_dsl/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ def highlight(self, *fields, **kwargs):
}
}
If you want to have different options for different fields you can call ``highlight`` twice::
If you want to have different options for different fields
you can call ``highlight`` twice::
Search().highlight('title', fragment_size=50).highlight('body', fragment_size=100)
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch_dsl/update_by_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def script(self, **kwargs):
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html
for more details.
Note: the API only accepts a single script, so calling the script multiple times will overwrite.
Note: the API only accepts a single script, so
calling the script multiple times will overwrite.
Example::
Expand Down
2 changes: 1 addition & 1 deletion examples/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Index:

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

Expand Down
5 changes: 3 additions & 2 deletions examples/search_as_you_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"""
Example ``Document`` with search_as_you_type field datatype and how to search it.
When creating a field with search_as_you_type datatype ElasticSearch creates additional subfields to enable efficient
as-you-type completion, matching terms at any position within the input.
When creating a field with search_as_you_type datatype ElasticSearch creates additional
subfields to enable efficient as-you-type completion, matching terms at any position
within the input.
To custom analyzer with ascii folding allow search to work in different languages.
"""
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def lint(session):
session.install("flake8", "black")

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


Expand Down
2 changes: 1 addition & 1 deletion test_elasticsearch_dsl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def dummy_response():
"_type": "company",
"_id": "elasticsearch",
"_score": 12.0,
"_source": {"city": "Amsterdam", "name": "Elasticsearch",},
"_source": {"city": "Amsterdam", "name": "Elasticsearch"},
},
{
"_index": "test-index",
Expand Down
2 changes: 1 addition & 1 deletion test_elasticsearch_dsl/test_aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_filter_aggregation_as_nested_agg():

assert {
"terms": {"field": "tags"},
"aggs": {"filtered": {"filter": {"term": {"f": 42}},}},
"aggs": {"filtered": {"filter": {"term": {"f": 42}}}},
} == a.to_dict()


Expand Down
2 changes: 1 addition & 1 deletion test_elasticsearch_dsl/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def test_to_dict_with_meta_includes_custom_index():
d = MySubDoc(title="hello")
d.meta.index = "other-index"

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


def test_to_dict_without_skip_empty_will_include_empty_fields():
Expand Down
14 changes: 7 additions & 7 deletions test_elasticsearch_dsl/test_faceted_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def test_query_is_created_properly():
assert {
"aggs": {
"_filter_tags": {
"filter": {"match_all": {},},
"filter": {"match_all": {}},
"aggs": {"tags": {"terms": {"field": "tags"}}},
},
"_filter_category": {
"filter": {"match_all": {},},
"filter": {"match_all": {}},
"aggs": {"category": {"terms": {"field": "category.raw"}}},
},
},
Expand All @@ -68,11 +68,11 @@ def test_query_is_created_properly_with_sort_tuple():
assert {
"aggs": {
"_filter_tags": {
"filter": {"match_all": {},},
"filter": {"match_all": {}},
"aggs": {"tags": {"terms": {"field": "tags"}}},
},
"_filter_category": {
"filter": {"match_all": {},},
"filter": {"match_all": {}},
"aggs": {"category": {"terms": {"field": "category.raw"}}},
},
},
Expand All @@ -95,7 +95,7 @@ def test_filter_is_applied_to_search_but_not_relevant_facet():
"aggs": {"tags": {"terms": {"field": "tags"}}},
},
"_filter_category": {
"filter": {"match_all": {},},
"filter": {"match_all": {}},
"aggs": {"category": {"terms": {"field": "category.raw"}}},
},
},
Expand Down Expand Up @@ -124,11 +124,11 @@ def test_filters_are_applied_to_search_ant_relevant_facets():
assert {
"aggs": {
"_filter_tags": {
"filter": {"terms": {"category.raw": ["elastic"]},},
"filter": {"terms": {"category.raw": ["elastic"]}},
"aggs": {"tags": {"terms": {"field": "tags"}}},
},
"_filter_category": {
"filter": {"terms": {"tags": ["python", "django"]},},
"filter": {"terms": {"tags": ["python", "django"]}},
"aggs": {"category": {"terms": {"field": "category.raw"}}},
},
},
Expand Down
2 changes: 1 addition & 1 deletion test_elasticsearch_dsl/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_field_from_dict():
def test_multi_fields_are_accepted_and_parsed():
f = field.construct_field(
"text",
fields={"raw": {"type": "keyword"}, "eng": field.Text(analyzer="english"),},
fields={"raw": {"type": "keyword"}, "eng": field.Text(analyzer="english")},
)

assert isinstance(f, field.Text)
Expand Down
Loading

0 comments on commit e03209a

Please sign in to comment.