Skip to content

Commit

Permalink
fix pylint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
geritwagner committed Oct 16, 2024
1 parent df758b8 commit 8dfc628
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 11 deletions.
9 changes: 6 additions & 3 deletions colrev/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ def has_changes(self, relative_path: Path, *, change_type: str = "all") -> bool:
path_changed = path_str in diff_head
elif change_type == "unstaged":
path_changed = path_str in unstaged_changes
else:
return False
return path_changed

def _sleep_util_git_unlocked(self) -> None:
Expand Down Expand Up @@ -509,7 +511,8 @@ def get_commit_message(self, *, commit_nr: int) -> str:
assert commit_nr == 0 # extension : implement other cases
if commit_nr == 0:
cmsg = master.commit.message
return cmsg
return cmsg
return ""

def _add_record_changes(self) -> None:
"""Add changes in records to git"""
Expand Down Expand Up @@ -597,8 +600,8 @@ def remote_ahead(self) -> bool: # pragma: no cover
_,
nr_commits_ahead,
) = self._get_remote_commit_differences()
if nr_commits_ahead > 0:
return True
if nr_commits_ahead > 0:
return True
return False

def pull_if_repo_clean(self) -> None: # pragma: no cover
Expand Down
6 changes: 4 additions & 2 deletions colrev/env/tei_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ def _get_reference_author_string(self, reference: Element) -> str:
authors_node = reference.find(self.ns["tei"] + "analytic")
elif reference.find(self.ns["tei"] + "monogr") is not None:
authors_node = reference.find(self.ns["tei"] + "monogr")
else:
return ""

if authors_node is not None:
for author_node in authors_node.iterfind(self.ns["tei"] + "author"):
Expand Down Expand Up @@ -555,9 +557,9 @@ def _get_dict_from_reference(self, reference: Element) -> dict:
Fields.ENTRYTYPE: entrytype,
Fields.BOOKTITLE: self._get_reference_monograph_string(reference),
}
elif entrytype == ENTRYTYPES.MISC:
else:
ref_rec = {
Fields.ENTRYTYPE: entrytype,
Fields.ENTRYTYPE: ENTRYTYPES.MISC,
}
ref_rec = {**ground_dict, **ref_rec}

Expand Down
4 changes: 4 additions & 0 deletions colrev/loader/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def get_nr_records(cls, filename: Path) -> int:
data = pd.read_csv(filename)
elif filename.name.endswith((".xls", ".xlsx")):
data = pd.read_excel(filename, dtype=str)
else:
raise NotImplementedError
count = len(data)
return count

Expand All @@ -56,6 +58,8 @@ def load_records_list(self) -> list:
data = pd.read_excel(
self.filename, dtype=str
) # dtype=str to avoid type casting
else:
raise NotImplementedError

except pd.errors.ParserError as exc: # pragma: no cover
raise colrev_exceptions.ImportException(
Expand Down
5 changes: 3 additions & 2 deletions colrev/ops/distribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ def main(self, *, path: Path, target: Path) -> None:
self.review_manager.settings.sources.append(new_source)
self.review_manager.save_settings()

if 0 != len(import_records):
record_id = int(self.get_next_id(bib_file=target_bib_file))
if 0 == len(import_records):
return

record_id = int(self.get_next_id(bib_file=target_bib_file))
record[Fields.ID] = f"{record_id}".rjust(10, "0")
record.update(file=str(target_pdf_path))
import_records.append(record)
Expand Down
7 changes: 3 additions & 4 deletions colrev/ops/pdf_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def link_pdf(
def get_target_filepath(self, record: colrev.record.record.Record) -> Path:
"""Get the target filepath for a PDF"""

target_filepath = self.review_manager.paths.PDF_DIR / Path(
f"{record.data['ID']}.pdf"
)
if self.filepath_directory_pattern == Fields.YEAR:
target_filepath = self.review_manager.paths.PDF_DIR / Path(
f"{record.data.get('year', 'no_year')}/{record.data['ID']}.pdf"
Expand All @@ -120,10 +123,6 @@ def get_target_filepath(self, record: colrev.record.record.Record) -> Path:
target_filepath = self.review_manager.paths.PDF_DIR / Path(
f"{record.data['volume']}/{record.data['ID']}.pdf"
)
else:
target_filepath = self.review_manager.paths.PDF_DIR / Path(
f"{record.data['ID']}.pdf"
)

return target_filepath

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def _export(self, *, selected_records: dict) -> None:

elif self.settings.bib_format is BibFormats.EXCEL:
export_filepath = self.endpoint_path / Path("references.xlsx")
else:
raise NotImplementedError

write_file(records_dict=selected_records, filename=export_filepath)

Expand Down
1 change: 1 addition & 0 deletions colrev/packages/crossref/src/crossref_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def _get_throttling_time(self) -> float:
)

# pylint: disable=too-many-arguments
# pylint: disable=too-many-positional-arguments
def retrieve(
self,
endpoint: str,
Expand Down
2 changes: 2 additions & 0 deletions colrev/packages/europe_pmc/src/europe_pmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def add_endpoint(
search_parameters={"query": query},
comment="",
)
else:
raise NotImplementedError
else:
raise NotImplementedError

Expand Down
2 changes: 2 additions & 0 deletions colrev/packages/ieee/src/ieee.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def add_endpoint(
search_parameters=search_parameters,
comment="",
)
else:
raise NotImplementedError

elif search_type == SearchType.DB:
search_source = operation.create_db_source(
Expand Down
2 changes: 2 additions & 0 deletions colrev/packages/pubmed/src/pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def add_endpoint(
search_parameters=query,
comment="",
)
else:
raise NotImplementedError
else:
raise NotImplementedError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def _get_semantic_scholar_api(
_search_return = self.author_search(params=params, rerun=rerun)
else:
self.review_manager.logger.info("No search parameters were found.")
raise NotImplementedError

return _search_return

Expand Down

0 comments on commit 8dfc628

Please sign in to comment.