refactor: speed up docstring checker#45009
Merged
tarekziade merged 5 commits intomainfrom Mar 27, 2026
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
ydshieh
reviewed
Mar 26, 2026
ydshieh
reviewed
Mar 26, 2026
Collaborator
ydshieh
left a comment
There was a problem hiding this comment.
I have a few (rather minor) questions and suggestions.
But overall LGTM and cache is always nice!
| # First, identify processor classes to track method context (only top-level classes) | ||
| processor_classes: set[str] = set() | ||
| for node in ast.walk(tree): | ||
| for node in tree.body: |
Collaborator
There was a problem hiding this comment.
is this change from the fact "(only top-level classes)"
Collaborator
There was a problem hiding this comment.
(maybe explain why only top-level now, in PR page or within code)
Collaborator
Author
There was a problem hiding this comment.
yes, we narrow the ast walk to module-level model classes.
zucchini-nlp
pushed a commit
to zucchini-nlp/transformers
that referenced
this pull request
Mar 27, 2026
* speed up docstring checker * add doctsrings and improve test readability * fmt * refactor cache so it's owned by a single function and the flow is clearer * adopt test_fetcher style for cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This patch improves the docstring checker implementation (redundant AST walks) and adds cache.
For the AST calls, 2.3x speedup check_docstrings.py --check_all on my M1: