Skip to content

Commit 2fe9768

Browse files
committed
format etc.
1 parent b398a60 commit 2fe9768

59 files changed

Lines changed: 224 additions & 151 deletions

File tree

Some content is hidden

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

colrev/loader/load_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,8 @@ def load_df(
264264
filename: Path,
265265
) -> pd.DataFrame:
266266
"""Load a file and return records as a DataFrame."""
267-
assert isinstance(
268-
filename, Path
269-
), f"filename must be a Path object, not {type(filename)}"
267+
if not isinstance(filename, Path):
268+
raise TypeError(f"filename must be a Path object, not {type(filename)}")
270269
record_dict = load(filename)
271270
return pd.DataFrame.from_dict(record_dict, orient="index")
272271

colrev/ops/checker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def _check_search_history_files(self) -> None:
208208
)
209209

210210
def _retrieve_ids_from_bib(self, *, file_path: Path) -> list:
211-
assert file_path.suffix == ".bib"
211+
if file_path.suffix != ".bib":
212+
raise AssertionError(f"Unexpected file suffix: {file_path.suffix}")
212213
record_ids = []
213214
with open(file_path, encoding="utf8") as file:
214215
line = file.readline()

colrev/ops/dedupe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ def apply_merges(
381381
if non_existing_ids:
382382
print(f"Non-existing IDs: {non_existing_ids}")
383383
print(f"Records IDs: {records.keys()}")
384-
assert not non_existing_ids, "Not all IDs from id_sets are present in records"
384+
if non_existing_ids:
385+
raise AssertionError("Not all IDs from id_sets are present in records")
385386

386387
# Notify users about items with only one unique ID
387388
for id_set in id_sets:
@@ -531,7 +532,8 @@ def _revert_merge_for_records(
531532
if origins == hist_recs[rid].get(Fields.ORIGIN, []):
532533
continue
533534
if any(orig in origins for orig in hist_rec.get(Fields.ORIGIN, [])):
534-
assert hist_rec[Fields.ID] not in unmerged_records
535+
if hist_rec[Fields.ID] in unmerged_records:
536+
raise AssertionError("Historical record ID unexpectedly present in unmerged records")
535537
hist_rec.update({Fields.STATUS: RecordState.md_processed})
536538
self.review_manager.logger.info(
537539
f"add historical record: {hist_rec[Fields.ID]}"

colrev/ops/init/readme.md

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

33
This repository is based on the [ColRev](https://github.com/CoLRev-Environment/colrev) standard.
44

5-
```
5+
```bash
66
# To work on this project, run
77
colrev clone URL
88

colrev/ops/load.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ def load_active_sources(self, *, include_md: bool = False) -> list:
449449
checker.check_sources()
450450
sources_settings = []
451451
for source in self.review_manager.settings.sources:
452-
assert isinstance(source, colrev.search_file.ExtendedSearchFile)
452+
if not isinstance(source, colrev.search_file.ExtendedSearchFile):
453+
raise AssertionError("Expected source to be ExtendedSearchFile")
453454
source.search_type = SearchType(source.search_type)
454455
source.search_results_path = Path(source.search_results_path)
455456
sources_settings.append(source)

colrev/ops/search_api_feed.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def __init__(
111111
self._load_feed()
112112

113113
if prep_mode:
114-
assert records is not None
114+
if records is None:
115+
raise AssertionError("Retrieved records must not be None")
115116
self.verbose_mode = verbose_mode
116117
self.prep_mode = prep_mode
117118
self._retrieved_records_for_saving = False
@@ -504,10 +505,11 @@ def get_records(self) -> dict:
504505
def save(self, *, skip_print: bool = False) -> None:
505506
"""Save the feed file and records, printing post-run search infos."""
506507
if self.prep_mode:
507-
assert self._retrieved_records_for_saving, (
508-
"You must call get_records() before calling save() "
509-
"to ensure that the prepared (primary) records are saved."
510-
)
508+
if not self._retrieved_records_for_saving:
509+
raise AssertionError(
510+
"You must call get_records() before calling save() "
511+
"to ensure that the prepared (primary) records are saved."
512+
)
511513

512514
if not skip_print and not self.prep_mode:
513515
self._print_post_run_search_infos()

colrev/ops/upgrade.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,8 @@ def __init__(self, version_string: str) -> None:
949949
"""Initialize the instance."""
950950
if "+" in version_string:
951951
version_string = version_string[: version_string.find("+")]
952-
assert re.match(r"\d+\.\d+\.\d+$", version_string)
952+
if not re.match(r"\d+\.\d+\.\d+$", version_string):
953+
raise AssertionError(f"Invalid version string: {version_string}")
953954
self.major = int(version_string[: version_string.find(".")])
954955
self.minor = int(
955956
version_string[version_string.find(".") + 1 : version_string.rfind(".")]

colrev/ops/validate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ def _get_target_commit(self, *, scope: str, filter_setting: str = "") -> str:
578578
if scope in ["HEAD", "."]:
579579
scope = "HEAD~0"
580580
if scope.startswith("HEAD~"):
581-
assert scope.replace("HEAD~", "").isdigit()
581+
if not scope.replace("HEAD~", "").isdigit():
582+
raise AssertionError(f"Invalid scope value: {scope}")
582583
back_count = int(scope.replace("HEAD~", ""))
583584
for commit_item in git_repo.iter_commits():
584585
if back_count == 0:

colrev/package_manager/doc_registry_manager.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ def _initialize_from_colrev_monorepo(self, package_id: str) -> bool:
103103
) as file:
104104
self.package_metadata = toml.load(file)
105105

106-
assert str(self.package_dir).endswith(
107-
package_id.replace("colrev.", "")
108-
), package_id
106+
if not str(self.package_dir).endswith(package_id.replace("colrev.", "")):
107+
raise AssertionError(
108+
f"Unexpected package directory for {package_id}: {self.package_dir}"
109+
)
109110

110111
return True
111112
return False

colrev/packages/acm_digital_library/README.md

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

55
### DB search
66

7-
```
7+
```bash
88
colrev search --add colrev.acm_digital_library
99
```
1010

0 commit comments

Comments
 (0)