Only test the files impacted by changes in the diff (#12644)
* Base test * More test * Fix mistake * Add a docstring change * Add doc ignore * Add changes * Add recursive dep search * Add recursive dep search * save * Finalize test mapping * Fix bug * Print prettier * Ignore comments and empty lines * Make script runnable from anywhere * Need dev install * Like that * Adapt * Add as artifact * Try on torch tests * Fix yaml error * Install GitPython * Apply everywhere * Be more defensive * Revert to all tests if something is wrong * Install GitPython * Test if there are tests before launching. * Fixes * Fixes * Fixes * Fixes * Bash syntax is horrible * Be less stupid * Try differently * Typo * Typo * Typo * Style * Better name * Escape quotes * Ignore black unhelpful re-formatting * Not a docstring * Deal with inits in dependency map * Run all tests once PR is merged. * Add last job * Apply suggestions from code review Co-authored-by: Stas Bekman <stas00@users.noreply.github.com> * Stronger dependencies gather * Ignore empty lines too! * Clean up * Fix quality Co-authored-by: Stas Bekman <stas00@users.noreply.github.com>
This commit is contained in:
@@ -489,12 +489,14 @@ def style_file_docstrings(code_file, max_len=119, check_only=False):
|
||||
"""Style all docstrings in `code_file` to `max_len`."""
|
||||
with open(code_file, "r", encoding="utf-8", newline="\n") as f:
|
||||
code = f.read()
|
||||
splits = code.split('"""')
|
||||
# fmt: off
|
||||
splits = code.split('\"\"\"')
|
||||
splits = [
|
||||
(s if i % 2 == 0 or _re_doc_ignore.search(splits[i - 1]) is not None else style_docstring(s, max_len=max_len))
|
||||
for i, s in enumerate(splits)
|
||||
]
|
||||
clean_code = '"""'.join(splits)
|
||||
clean_code = '\"\"\"'.join(splits)
|
||||
# fmt: on
|
||||
|
||||
diff = clean_code != code
|
||||
if not check_only and diff:
|
||||
|
||||
Reference in New Issue
Block a user