-
Notifications
You must be signed in to change notification settings - Fork 33.1k
[typings] Automatically type decorator return types as tuple | X
#43446
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
Open
tomaarsen
wants to merge
23
commits into
huggingface:main
Choose a base branch
from
tomaarsen:feat/auto_decorator_return_typing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bffa963
Automatically update can_return_tuple/check_model_inputs wrapped retu…
tomaarsen 6762069
Add check_decorator_return_types.py script to check against 'tuple | X'
tomaarsen fa9caf7
Run checking script & fix existing typings
tomaarsen abaca9c
Fix blt by removing check_model_inputs; matching other classes
tomaarsen 3652612
Use can_return_tuple on altclip
tomaarsen 9d9666a
Add docstring for check_model_inputs / can_return_tuple
tomaarsen 99d5deb
Import ParamSpec via generic as we're in Python 3.10+
tomaarsen 6ad9269
Add check_decorator_return_types to fix-repo & check-repo
tomaarsen a9afbdb
Remove some dead code
tomaarsen aa97fc6
Update _decorator_name to not check for our targets yet
tomaarsen f71a072
Use src/transformers/models path instead
tomaarsen 63155b6
Revert "Use src/transformers/models path instead"
tomaarsen 864a6a7
Use src/transformers/models path instead
tomaarsen 456ee32
Simplify _is_none_annotation
tomaarsen 3b0808e
Explain why super() is skipped
tomaarsen dbd43d6
Add comments for ParamSpec/TypeVar linking to Python docs
tomaarsen 688be4b
Make style
tomaarsen 3fd9571
Move decorator typing comments around
tomaarsen 155fad7
Merge branch 'main' into feat/auto_decorator_return_typing
tomaarsen ea9df1d
Merge branch 'main' into feat/auto_decorator_return_typing
tomaarsen bc81a60
Rerun utils/check_decorator_return_types.py
tomaarsen b05bc5d
Update incorrect typings on modular classes that inherit decorators
tomaarsen e3da0ce
Merge branch 'main' into feat/auto_decorator_return_typing
tomaarsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Reviewer note: There are only 2 actual code changes under
src/transformers/models, and this is one of them. This class copies from CLAP, which uses@can_return_tuple, but this class did not. I've added it here.I also updated this class and the CLAP variant to remove the
return_dict = return_dict if return_dict is not None else self.config.use_return_dictline, as that was just dead code.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.
nice! Ideally would be great to start using
check_model_inputsfor pretrained models. Though it might require more manual work than current state of PR