-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add deprecation warning to jsonrpc endpoints dropped in EIP 1474 #1271
Conversation
966776d
to
e578dd2
Compare
web3/eth.py
Outdated
@@ -374,6 +374,7 @@ def contract(self, | |||
def setContractFactory(self, contractFactory): | |||
self.defaultContractFactory = contractFactory | |||
|
|||
@deprecated_for("Dropped in EIP 1474") |
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 message a user will get is going to be awkward
web3.py/web3/utils/decorators.py
Line 54 in e578dd2
"%s is deprecated in favor of %s" % (to_wrap.__name__, replace_message), |
This probably warrants just manually raising the proper deprecation warning exception. Similarly, in v5, we should potentially not fully remove the methods, but make them do a raise DeprecationWarning()
which I believe that when raised as an exception is just like normal exception raising. This way people aren't greeted with an AttributeError
but a nice explanation of why the method they are accessing is missing.
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.
@pipermerriam 👍 If we're just going to raise DeprecationWarning()
in v5 - should I close this PR since the warning is no longer needed in v4? Or should I continue with v4 warnings
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.
So warnings don't break codeflow, they just dump information out so a user who's watching for them knows something is going away. Using the raise
syntax breaks code flow so they are two separate mechanisms. These can be easy to mixup since the exception class is called DeprecationWarning
but they are to different mechanisms that use the same class.
warning.warn(...)
- forv4
raise DeprecationWarning
- forv5
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.
Are we switching to the raise DeprecationWarning
for all methods we're deprecating in v5? Or just specific ones?
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.
raise DeprecationWarning
should only be used if it was previously deprecated meaning that users of v4
would have already been warned.
Otherwise it should use warning.warn(...)
to begin giving users a warning
9bf7b39
to
54e685d
Compare
79f2ae4
to
048826f
Compare
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.
Last thing. Can you add tests for these to show they properly raise the warning with pytest.warns(...)
.
Same for v5 branch, tests showing the deprecation error gets properly raised. Good to with those changes.
bd75fa1
to
5832f49
Compare
5832f49
to
530d725
Compare
What was wrong?
Add deprecation warnings for jsonrpc endpoints dropped in EIP 1474
Cute Animal Picture