-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix make fix-copies with type annotations #13586
Conversation
@patrickvonplaten Can you double-check the changes in HuBERT are good? |
@sgugger I pulled this PR and found there is 1 edge case remained:
Change the above line to
or
or
Currently (with the work in this PR), these changes won't be copied to
|
Ok for HuBERT |
@ydshieh This is not a edge case but the way the check copies utility has been implemented. It does not check for the class name, function name, just the code inside. This is why the introduction line is ignored in the check. |
@sgugger , Thanks, I understand now. However, I personally feel this is a bit strange. In my work on encoder-decoder, I need to add cross-attention and cache mechanism to some models, and these involve changing some return value types. And the way Moreover, if the function name & signature have multiple lines, the added or removed parameters will be copied (suppose they are not in the same line as the function name). This is somehow inconsistent with the single-line case above. I will let Hugging Face to decide if it is necessary to address this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue you mention @ydshieh is a real issue but appears in very rare cases - I think while it would be nice to update it, it does require a significant rewrite for a less significant gain.
What does this PR do?
As pointed out by #13583, there is a bug in the current check_copies utils when a function has a very long signature and a type annotation. This was due to a regex only checking for
):
instead of):
or) -> type:
. This PR fixes that and pushes some changes due to divergences that went undetected.Fixes #13583