MCPcopy Index your code
hub / github.com/huggingface/diffusers / diff_is_docstring_only

Function diff_is_docstring_only

utils/tests_fetcher.py:183–206  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

181
182
183def 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
209def diff_contains_doc_examples(repo: Repo, branching_point: str, filename: str) -> bool:

Callers 1

get_diffFunction · 0.85

Calls 2

checkout_commitFunction · 0.85
clean_codeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…