Skip to content
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

Merged
merged 1 commit into from
Mar 12, 2019

Conversation

njgheorghita
Copy link
Contributor

What was wrong?

Add deprecation warnings for jsonrpc endpoints dropped in EIP 1474

Cute Animal Picture

image

@njgheorghita njgheorghita force-pushed the v4-deprecate-endpoints branch from 966776d to e578dd2 Compare March 11, 2019 14:38
web3/eth.py Outdated
@@ -374,6 +374,7 @@ def contract(self,
def setContractFactory(self, contractFactory):
self.defaultContractFactory = contractFactory

@deprecated_for("Dropped in EIP 1474")
Copy link
Member

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

"%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.

Copy link
Contributor Author

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

Copy link
Member

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(...) - for v4
  • raise DeprecationWarning - for v5

Copy link
Collaborator

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?

Copy link
Member

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

@njgheorghita njgheorghita force-pushed the v4-deprecate-endpoints branch 3 times, most recently from 9bf7b39 to 54e685d Compare March 11, 2019 19:11
@njgheorghita njgheorghita force-pushed the v4-deprecate-endpoints branch 2 times, most recently from 79f2ae4 to 048826f Compare March 11, 2019 19:19
Copy link
Member

@pipermerriam pipermerriam left a 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 :shipit: with those changes.

@njgheorghita njgheorghita force-pushed the v4-deprecate-endpoints branch 5 times, most recently from bd75fa1 to 5832f49 Compare March 12, 2019 11:48
@njgheorghita njgheorghita force-pushed the v4-deprecate-endpoints branch from 5832f49 to 530d725 Compare March 12, 2019 12:04
@njgheorghita njgheorghita merged commit 0048ff4 into ethereum:v4 Mar 12, 2019
@njgheorghita njgheorghita deleted the v4-deprecate-endpoints branch March 12, 2019 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants