Check if the diff is only in docstrings (or comments and whitespace) in a filename. Args: repo (`git.Repo`): A git repository (for instance the Transformers repo). branching_point (`str`): The commit reference of where to compare for the diff. filename (`str`): The
(repo: Repo, branching_point: str, filename: str)
| 181 | |
| 182 | |
| 183 | def diff_is_docstring_only(repo: Repo, branching_point: str, filename: str) -> bool: |
| 184 | """ |
| 185 | Check if the diff is only in docstrings (or comments and whitespace) in a filename. |
| 186 | |
| 187 | Args: |
| 188 | repo (`git.Repo`): A git repository (for instance the Transformers repo). |
| 189 | branching_point (`str`): The commit reference of where to compare for the diff. |
| 190 | filename (`str`): The filename where we want to know if the diff isonly in docstrings/comments. |
| 191 | |
| 192 | Returns: |
| 193 | `bool`: Whether the diff is docstring/comments only or not. |
| 194 | """ |
| 195 | folder = Path(repo.working_dir) |
| 196 | with checkout_commit(repo, branching_point): |
| 197 | with open(folder / filename, "r", encoding="utf-8") as f: |
| 198 | old_content = f.read() |
| 199 | |
| 200 | with open(folder / filename, "r", encoding="utf-8") as f: |
| 201 | new_content = f.read() |
| 202 | |
| 203 | old_content_clean = clean_code(old_content) |
| 204 | new_content_clean = clean_code(new_content) |
| 205 | |
| 206 | return old_content_clean == new_content_clean |
| 207 | |
| 208 | |
| 209 | def diff_contains_doc_examples(repo: Repo, branching_point: str, filename: str) -> bool: |
no test coverage detected
searching dependent graphs…