Checkers¶
Base¶
base ¶
BaseChecker ¶
BaseChecker(module: PythonModule)
Bases: ABC
Source code in docstr_health/checkers/base.py
13 14 15 16 17 | |
check_module abstractmethod ¶
check_module() -> ModuleReport | None
Check the module and return a report.
Subclasses must implement this method to define module-level analysis logic.
Returns:
| Name | Type | Description |
|---|---|---|
ModuleReport | ModuleReport | None | Report with all metrics for statistics. |
Source code in docstr_health/checkers/base.py
19 20 21 22 23 24 25 26 27 28 | |
Docstring checker¶
docstring ¶
DocstringChecker ¶
DocstringChecker(
module: PythonModule, settings: AppSettings
)
Bases: BaseChecker
Source code in docstr_health/checkers/docstring.py
13 14 15 16 17 18 19 20 21 22 | |
inspected_statuses instance-attribute ¶
inspected_statuses = {
"bad": 0,
"good": 0,
"special": 0,
"epic": 0,
"skipped": 0,
}
module_status property ¶
module_status: str
Module status is calculated as follows: All bad OR bad > threshold_bad% default: 80 -> bad bad > threshold_warning% default: 60 -> warning epic > threshold_epic% default: 50 -> epic special > threshold_special% default: 50 OR tied -> special otherwise -> good
Rounds down when special and epic are tied.
get_statistics ¶
get_statistics() -> list[Text]
Source code in docstr_health/checkers/docstring.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
check_module ¶
check_module() -> ModuleReport | None
Source code in docstr_health/checkers/docstring.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
inspect_func_status ¶
inspect_func_status(
func: PythonFunction,
) -> StatusDocstring
Checking the state of a function docstring.
Source code in docstr_health/checkers/docstring.py
133 134 135 136 | |
get_func_status_text ¶
get_func_status_text(func: PythonFunction) -> Text
Source code in docstr_health/checkers/docstring.py
138 139 140 | |
check_docstring ¶
check_docstring(
docstring: str | object | None,
) -> StatusDocstring
Evaluate the quality of a docstring and assign a status.
The evaluation follows a priority based on content presence and keyword matching: 1. BAD: Docstring is missing or empty. 2. GOOD: Has content but lacks EPIC/SPECIAL keywords. 3. SPECIAL: Contains basic parameter keywords. 4. EPIC: Contains advanced keywords.
This method also increments the corresponding counter in self.inspected_statuses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docstring | str | object | None | The docstring text to evaluate, or None. | required |
Returns:
| Name | Type | Description |
|---|---|---|
StatusDocstring | StatusDocstring | The matched status enum value. |
Source code in docstr_health/checkers/docstring.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
Project checker¶
project ¶
ProjectChecker ¶
ProjectChecker(source: BaseSource, settings: AppSettings)
Source code in docstr_health/checkers/project.py
14 15 16 17 18 19 20 | |
modules instance-attribute ¶
modules = [
PythonModule(file_path=file)
for file in self._python_files
]
get_quantity_of_func_type ¶
get_quantity_of_func_type() -> dict
Source code in docstr_health/checkers/project.py
26 27 28 29 30 31 | |
get_count_modules ¶
get_count_modules() -> int
Source code in docstr_health/checkers/project.py
33 34 | |
get_statuses_stat ¶
get_statuses_stat() -> Counter
Source code in docstr_health/checkers/project.py
36 37 38 | |
get_project_report ¶
get_project_report()
Source code in docstr_health/checkers/project.py
40 41 | |
docstring_check ¶
docstring_check() -> Generator[PythonModule, None, None]
Source code in docstr_health/checkers/project.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
CI failure checker¶
ci_failure ¶
CiFailureChecker ¶
CiFailureChecker(project_report: ProjectReport)
Source code in docstr_health/checkers/ci_failure.py
10 11 | |
assertion ¶
assertion() -> None
Source code in docstr_health/checkers/ci_failure.py
13 14 15 16 17 18 19 20 21 22 23 24 | |