Skip to content

Commit 6a3306f

Browse files
committed
remove unnecessary try...else
1 parent 64c5c5b commit 6a3306f

File tree

8 files changed

+9
-17
lines changed

8 files changed

+9
-17
lines changed

share/models/index_backfill.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,4 @@ def task__schedule_index_backfill(self, index_backfill_pk):
185185
except Exception as error:
186186
_index_backfill.pls_mark_error(error)
187187
raise error
188-
else:
189-
_index_backfill.pls_note_scheduling_has_finished()
188+
_index_backfill.pls_note_scheduling_has_finished()

trove/derive/osfmap_json.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ def _list_or_single_value(self, predicate_iri: str, json_list: list[JsonValue])
151151
(_only_obj,) = json_list
152152
except ValueError:
153153
return None
154-
else:
155-
return _only_obj
154+
return _only_obj
156155
return (
157156
sorted(json_list, key=json.dumps)
158157
if len(json_list) > 1

trove/render/cardsearch_atom.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,4 @@ def _atom_id(self, card_iri: str) -> str:
7373
_uuid = rdf.iri_minus_namespace(card_iri, namespace=trove_indexcard_namespace())
7474
except ValueError:
7575
return card_iri
76-
else:
77-
return f'urn:uuid:{_uuid}'
76+
return f'urn:uuid:{_uuid}'

trove/render/jsonld.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ def _list_or_single_value(self, predicate_iri: str, objectlist: list[JsonValue])
157157
(_only_obj,) = objectlist
158158
except ValueError:
159159
return None
160-
else:
161-
return _only_obj
160+
return _only_obj
162161
if predicate_iri in _PREDICATES_OF_FLEXIBLE_CARDINALITY and len(objectlist) == 1:
163162
return objectlist[0]
164163
return sorted(objectlist, key=_naive_sort_key)

trove/trovesearch/trovesearch_gathering.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,7 @@ def _osfmap_or_unknown_iri_as_json(iri: str) -> rdf.Literal:
497497
_twopledict = osfmap.OSFMAP_THESAURUS[iri]
498498
except KeyError:
499499
return rdf.literal_json({'@id': iri})
500-
else:
501-
return _osfmap_json({iri: _twopledict}, focus_iri=iri)
500+
return _osfmap_json({iri: _twopledict}, focus_iri=iri)
502501

503502

504503
def _valuesearch_result_as_json(result: ValuesearchResult) -> rdf.Literal:

trove/util/queryparams.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ def get_single_value(
113113
(_singlevalue,) = _paramvalues
114114
except ValueError:
115115
raise trove_exceptions.InvalidRepeatedQueryParam(str(queryparam_name))
116-
else:
117-
return _singlevalue
116+
return _singlevalue
118117

119118

120119
def get_bool_value(

trove/util/trove_params.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def _gather_shorthand(cls, queryparams: _qp.QueryparamDict) -> rdf.IriShorthand:
7272
(_shortname,) = _qp_name.bracketed_names
7373
except ValueError:
7474
raise trove_exceptions.InvalidQueryParamName(_qp_name)
75-
else:
76-
_prefixmap[_shortname] = _iri
75+
_prefixmap[_shortname] = _iri
7776
_shorthand = cls._default_shorthand()
7877
if _prefixmap:
7978
_shorthand = _shorthand.with_update(_prefixmap)

trove/views/ingest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ def post(self, request: HttpRequest) -> HttpResponse:
6161
except trove_exceptions.DigestiveError as e:
6262
logger.exception(str(e))
6363
return http.HttpResponse(str(e), status=HTTPStatus.BAD_REQUEST)
64-
else:
65-
# TODO: include (link to?) extracted card(s)
66-
return http.HttpResponse(status=HTTPStatus.CREATED)
64+
# TODO: include (link to?) extracted card(s)
65+
return http.HttpResponse(status=HTTPStatus.CREATED)
6766

6867
def delete(self, request: HttpRequest) -> HttpResponse:
6968
# TODO: cleaner permissions

0 commit comments

Comments
 (0)