Skip to content

Commit bc9b34b

Browse files
committed
Update pre-commit hooks
1 parent 6254440 commit bc9b34b

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ repos:
33
rev: 5.9.3
44
hooks:
55
- id: isort
6+
- repo: https://github.com/psf/black
7+
rev: 21.9b0
8+
hooks:
9+
- id: black
610
- repo: https://github.com/pre-commit/pre-commit-hooks
711
rev: v4.0.1
812
hooks:

pysolr.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ def __init__(self, decoded, next_page_query=None):
295295
self.qtime = decoded.get("responseHeader", {}).get("QTime", None)
296296
self.grouped = decoded.get("grouped", {})
297297
self.nextCursorMark = decoded.get("nextCursorMark", None)
298-
self._next_page_query = self.nextCursorMark is not None \
299-
and next_page_query or None
298+
self._next_page_query = (
299+
self.nextCursorMark is not None and next_page_query or None
300+
)
300301

301302
def __len__(self):
302303
if self._next_page_query:
@@ -844,10 +845,12 @@ def search(self, q, search_handler=None, **kwargs):
844845

845846
cursorMark = params.get("cursorMark", None)
846847
if cursorMark != decoded.get("nextCursorMark", cursorMark):
848+
847849
def next_page_query():
848850
nextParams = params.copy()
849851
nextParams["cursorMark"] = decoded["nextCursorMark"]
850852
return self.search(search_handler=search_handler, **nextParams)
853+
851854
return self.results_cls(decoded, next_page_query)
852855
else:
853856
return self.results_cls(decoded)
@@ -984,7 +987,7 @@ def add(
984987
waitSearcher=None,
985988
overwrite=None,
986989
handler="update",
987-
min_rf=None
990+
min_rf=None,
988991
):
989992
"""
990993
Adds or updates documents.
@@ -1121,14 +1124,14 @@ def delete(
11211124
if doc_id:
11221125
et = ElementTree.Element("delete")
11231126
for one_doc_id in doc_id:
1124-
subelem = ElementTree.SubElement(et, 'id')
1127+
subelem = ElementTree.SubElement(et, "id")
11251128
subelem.text = one_doc_id
11261129
m = ElementTree.tostring(et)
11271130
else:
11281131
raise ValueError("The list of documents to delete was empty.")
11291132
elif q is not None:
11301133
et = ElementTree.Element("delete")
1131-
subelem = ElementTree.SubElement(et, 'query')
1134+
subelem = ElementTree.SubElement(et, "query")
11321135
subelem.text = q
11331136
m = ElementTree.tostring(et)
11341137

@@ -1335,7 +1338,7 @@ def _get_url(self, url, params=None, headers=None):
13351338
if params is None:
13361339
params = {}
13371340
if headers is None:
1338-
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
1341+
headers = {"Content-Type": "application/x-www-form-urlencoded"}
13391342

13401343
resp = requests.get(url, data=safe_urlencode(params), headers=headers)
13411344
return force_unicode(resp.content)

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
universal = 1
33

44
[flake8]
5-
exclude = .venv,node_modules,concordia/settings_dev_*.py
5+
exclude = .venv,node_modules
66
max-line-length = 88
77
enable-extensions = G
88

99
[isort]
1010
default_section = THIRDPARTY
11+
ensure_newline_before_comments = True
1112
force_grid_wrap = 0
1213
include_trailing_comma = True
1314
known_first_party = pysolr

tests/test_client.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ def test_custom_results_class(self):
281281
self.assertIn("response", results)
282282

283283
def test_cursor_traversal(self):
284-
solr = Solr('http://localhost:8983/solr/core0')
284+
solr = Solr("http://localhost:8983/solr/core0")
285285

286-
expected = solr.search(q="*:*", rows=len(self.docs)*3, sort="id asc").docs
287-
results = solr.search(q='*:*', cursorMark="*", rows=2, sort="id asc")
286+
expected = solr.search(q="*:*", rows=len(self.docs) * 3, sort="id asc").docs
287+
results = solr.search(q="*:*", cursorMark="*", rows=2, sort="id asc")
288288
all_docs = list(results)
289289
self.assertEqual(len(expected), len(all_docs))
290290
self.assertEqual(len(results), len(all_docs))
@@ -760,12 +760,7 @@ def test__build_xml_doc_with_empty_values_and_field_updates(self):
760760
self.assertEqual(len(doc_xml), 134)
761761

762762
def test_build_json_doc_matches_xml(self):
763-
doc = {
764-
"id": "doc_1",
765-
"title": "",
766-
"price": 12.59,
767-
"popularity": 10
768-
}
763+
doc = {"id": "doc_1", "title": "", "price": 12.59, "popularity": 10}
769764

770765
doc_json = self.solr._build_json_doc(doc)
771766
doc_xml = self.solr._build_xml_doc(doc)
@@ -912,10 +907,10 @@ def test_delete(self):
912907

913908
# Test a query that would need to be quoted when using the XML API.
914909
# Ids with a "<" character will give an error using v3.9.0 or earlier
915-
self.solr.delete(id='cats<dogs')
910+
self.solr.delete(id="cats<dogs")
916911
# These will delete too much when using v3.9.0 or earlier.
917-
self.solr.delete(q='id:*</query><query> id:999 AND id:9999')
918-
self.solr.delete(id='doc_4</id><id>doc_3', commit=True)
912+
self.solr.delete(q="id:*</query><query> id:999 AND id:9999")
913+
self.solr.delete(id="doc_4</id><id>doc_3", commit=True)
919914

920915
# one simple doc should remain
921916
# parent documents were also deleted but children remain as orphans

0 commit comments

Comments
 (0)