Skip to content

Commit 9dfbaef

Browse files
docs: address PEP 257 docstring conventions across the codebase (#760)
* docs: add missing magic-method docstrings across codebase * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 67bbd93 commit 9dfbaef

222 files changed

Lines changed: 770 additions & 453 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/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,11 @@ class RecordState(Enum):
425425
# Note : TBD: rev_coded
426426

427427
def __str__(self) -> str:
428+
"""Return a string representation."""
428429
return f"{self.name}"
429430

430431
def __lt__(self, other) -> bool: # type: ignore
432+
"""Return whether this instance is less than another."""
431433
if self.__class__ == RecordState and other.__class__ == RecordState:
432434
return self.value < other.value
433435
raise NotImplementedError
@@ -593,6 +595,7 @@ class OperationsType(Enum):
593595
check = "check"
594596

595597
def __str__(self) -> str:
598+
"""Return a string representation."""
596599
return f"{self.name}"
597600

598601
@classmethod
@@ -625,6 +628,7 @@ class SortedEnumMeta(EnumMeta):
625628
def __init__(
626629
cls, name: str, bases: typing.Tuple[type, ...], classdict: dict
627630
) -> None:
631+
"""Initialize the instance."""
628632
super().__init__(name, bases, classdict)
629633
# Sort the members by their values
630634
# pylint: disable=unsubscriptable-object
@@ -652,9 +656,11 @@ def get_options(cls) -> typing.List[str]:
652656
return cls._member_names_
653657

654658
def __str__(self) -> str:
659+
"""Return a string representation."""
655660
return self.name
656661

657662
def __lt__(self, other: "SearchType") -> bool:
663+
"""Return whether this instance is less than another."""
658664
if isinstance(other, SearchType):
659665
return self.value < other.value
660666
return NotImplemented
@@ -670,6 +676,7 @@ class SearchSourceHeuristicStatus(Enum):
670676
todo = "to_be_implemented"
671677

672678
def __str__(self) -> str:
679+
"""Return a string representation."""
673680
return f"{self.name}" # pragma: no cover
674681

675682

@@ -701,6 +708,7 @@ def get_options(cls) -> typing.List[str]:
701708
return cls._member_names_
702709

703710
def __str__(self) -> str:
711+
"""Return a string representation."""
704712
return self.name
705713

706714

colrev/dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Dataset:
2828
"""The CoLRev dataset (records and their history in git)."""
2929

3030
def __init__(self, *, review_manager: colrev.review_manager.ReviewManager) -> None:
31+
"""Initialize the instance."""
3132
self.review_manager = review_manager
3233

3334
@cached_property

colrev/env/environment_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class EnvironmentManager:
2626
load_yaml = False
2727

2828
def __init__(self) -> None:
29+
"""Initialize the instance."""
2930
self.environment_registry = self.load_environment_registry()
3031
self._registered_ports: typing.List[str] = []
3132

colrev/env/grobid_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class GrobidService:
2121
GROBID_IMAGE = "lfoppiano/grobid:0.8.2"
2222

2323
def __init__(self) -> None:
24+
"""Initialize the instance."""
2425
colrev.env.docker_manager.DockerManager.build_docker_image(
2526
imagename=self.GROBID_IMAGE
2627
)

colrev/env/language_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self) -> None:
2424
# It performs particularly well for short strings (single words/word pairs)
2525
# The langdetect library is non-deterministic, especially for short strings
2626
# https://pypi.org/project/langdetect/
27-
27+
"""Initialize the instance."""
2828
self._lingua_language_detector = (
2929
LanguageDetectorBuilder.from_all_languages_with_latin_script().build()
3030
)

colrev/env/local_index.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(
3131
index_tei: bool = False,
3232
verbose_mode: bool = False,
3333
) -> None:
34+
"""Initialize the instance."""
3435
self.verbose_mode = verbose_mode
3536
self.environment_manager = colrev.env.environment_manager.EnvironmentManager()
3637
self._index_tei = index_tei

colrev/env/local_index_builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(
4444
index_tei: bool = False,
4545
verbose_mode: bool = False,
4646
) -> None:
47+
"""Initialize the instance."""
4748
self.verbose_mode = verbose_mode
4849
self.environment_manager = colrev.env.environment_manager.EnvironmentManager()
4950
self._index_tei = index_tei

colrev/env/local_index_sqlite.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class SQLiteIndex:
5454
def __init__(
5555
self, *, index_name: str, index_keys: list, reinitialize: bool
5656
) -> None:
57+
"""Initialize the instance."""
5758
self.index_name = index_name
5859
self.index_keys = index_keys
5960
self.connection = sqlite3.connect(
@@ -152,6 +153,7 @@ class SQLiteIndexRecord(SQLiteIndex):
152153
WHERE {LocalIndexFields.ID}=?"""
153154

154155
def __init__(self, *, reinitialize: bool = False) -> None:
156+
"""Initialize the instance."""
155157
super().__init__(
156158
index_name=self.INDEX_NAME,
157159
index_keys=self.KEYS,
@@ -266,6 +268,7 @@ class SQLiteIndexRankings(SQLiteIndex):
266268
SELECT_QUERY = f"SELECT * FROM {INDEX_NAME} WHERE journal_name = ?"
267269

268270
def __init__(self, *, reinitialize: bool = False) -> None:
271+
"""Initialize the instance."""
269272
super().__init__(
270273
index_name=self.INDEX_NAME,
271274
index_keys=self.KEYS,
@@ -306,6 +309,7 @@ class SQLiteIndexTOC(SQLiteIndex):
306309
INSERT_MANY_QUERY = f"INSERT INTO {INDEX_NAME} VALUES(?, ?)"
307310

308311
def __init__(self, *, reinitialize: bool = False) -> None:
312+
"""Initialize the instance."""
309313
super().__init__(
310314
index_name=self.INDEX_NAME,
311315
index_keys=self.KEYS,

0 commit comments

Comments
 (0)