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

Fix mypy tests for eth package #1362

Merged
merged 1 commit into from
Oct 6, 2018
Merged

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Oct 5, 2018

What was wrong?

Mypy tests were not being triggered for eth module.

How was it fixed?

  1. Fixed CircleCI setting
  2. Fixed some type hints errors

Cute Animal Picture

halloween

@@ -74,7 +74,8 @@ class ByzantiumVM(SpuriousDragonVM):
compute_difficulty = staticmethod(compute_byzantium_difficulty)
configure_header = configure_byzantium_header
make_receipt = staticmethod(make_byzantium_receipt)
get_uncle_reward = staticmethod(get_uncle_reward(EIP649_BLOCK_REWARD))
get_uncle_reward = get_uncle_reward(EIP649_BLOCK_REWARD)
get_uncle_reward = staticmethod(get_uncle_reward)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't understand why it works...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by works you mean why mypy is ok with it or why it works in the context of python.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For mypy.
The previous error message was:

eth/vm/forks/byzantium/__init__.py:77: error: Incompatible types in assignment (expression has type "staticmethod", base class "BaseVM" defined the type as "Callable[[int, BaseBlock], int]")
eth/vm/forks/constantinople/__init__.py:34: error: Incompatible types in assignment (expression has type "staticmethod", base class "BaseVM" defined the type as "Callable[[int, BaseBlock], int]")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's weird. This deserves a comment explaining why, and maybe a minute checking the mypy github issues to see if this is a known bug/deficiency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bug of mypy: python/mypy#5530
@pipermerriam do you think it's better to keep this current fix + comment the issue, or add # type: ignore + comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix + comment seems best.

@@ -74,7 +74,8 @@ class ByzantiumVM(SpuriousDragonVM):
compute_difficulty = staticmethod(compute_byzantium_difficulty)
configure_header = configure_byzantium_header
make_receipt = staticmethod(make_byzantium_receipt)
get_uncle_reward = staticmethod(get_uncle_reward(EIP649_BLOCK_REWARD))
get_uncle_reward = get_uncle_reward(EIP649_BLOCK_REWARD)
get_uncle_reward = staticmethod(get_uncle_reward)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by works you mean why mypy is ok with it or why it works in the context of python.

@@ -1,4 +1,4 @@
from hashlib import blake2b
from hashlib import blake2b # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why we have to type: ignore this.

@hwwhww hwwhww merged commit ee56b2c into ethereum:master Oct 6, 2018
@hwwhww hwwhww deleted the fix_mypy_ci branch October 6, 2018 12:22
@hwwhww hwwhww mentioned this pull request Jun 1, 2019
1 task
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.

2 participants