-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Replace assert statements with exceptions #24856
Conversation
try-except block was using AssesrtionError in except statement while the expected error is value error. Fixed the same.
try-except block was using AssesrtionError in except statement while the expected error is ValueError. Fixed the same. Note: While raising the ValueError args are passed to it, but later added again while handling the error (See the code snippet)
try-except block was using AssesrtionError in except statement while the expected error is ValueError. Fixed the same. Note: While raising the ValueError args are passed to it, but later added again while handling the error (See the code snippet)
Merge other commits
…it into ValueError
Changed == to !=
Merge all commits
Changed == to !=
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.
Thanks for the fixes! Note that the conversion scripts are exempt form the issue of replacing asserts to exceptions, since they are not really modules of the library.
Some of your modifications break the copied from mechanism. Could you quickly run make fix-copies
to fix that?
The documentation is not available anymore as the PR was closed or merged. |
* Changed AssertionError to ValueError try-except block was using AssesrtionError in except statement while the expected error is value error. Fixed the same. * Changed AssertionError to ValueError try-except block was using AssesrtionError in except statement while the expected error is ValueError. Fixed the same. Note: While raising the ValueError args are passed to it, but later added again while handling the error (See the code snippet) * Changed AssertionError to ValueError try-except block was using AssesrtionError in except statement while the expected error is ValueError. Fixed the same. Note: While raising the ValueError args are passed to it, but later added again while handling the error (See the code snippet) * Changed AssertionError to ValueError * Changed AssertionError to ValueError * Changed AssertionError to ValueError * Changed AssertionError to ValueError * Changed AssertionError to ValueError * Changed assert statement to ValueError based * Changed assert statement to ValueError based * Changed assert statement to ValueError based * Changed incorrect error handling from AssertionError to ValueError * Undoed change from AssertionError to ValueError as it is not needed * Reverted back to using AssertionError as it is not necessary to make it into ValueError * Fixed erraneous comparision Changed == to != * Fixed erraneous comparision Changed == to != * formatted the code * Ran make fix-copies
What does this PR do?
I have replaced the assert statements with appropriate exceptions in the directory
src/transformers/models/
with all models beginning witha
andb
letters.Also, I have corrected error handling at places where except statements were handling AssertionError, even thought it was never to be raised. Here is an example:
I changed the above to:
Fixes #12789
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@ArthurZucker @sgugger