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

MyPy missed type error #1240

Closed
CarlBeek opened this issue Jun 30, 2019 · 3 comments
Closed

MyPy missed type error #1240

CarlBeek opened this issue Jun 30, 2019 · 3 comments

Comments

@CarlBeek
Copy link
Contributor

In #1234 , MyPy missed that the a type was incorrect despite the object being passed to typed functions. Specifically, next_epoch was cast to a Shard type and passed into get_compact_committees_root which is typed to accept an Epoch.

Does anyone know why? (Particularly someone who understands Python typing better than I).

@protolambda
Copy link
Collaborator

Currently SSZ is set to coerce any uint input, but only if it's of the same byte length. All for readability and minimal changes (ugly wrapping in Slot/Epoch), as a lot had to be modified at the time of introducing typing.
See https://github.com/ethereum/eth2.0-specs/blob/2e41f2da3b12c7cf056ee7035ec4ec3a3a707ea1/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py#L111 if you like to change it.

@CarlBeek
Copy link
Contributor Author

I see, that makes a lot of sense. I don't really have an issue with it, I just think it partially defeats the purpose of static typing if we bypass such checks. I will look deeper into this and develop propper feelings one way or another post ❄️❄️❄️.

@JustinDrake
Copy link
Collaborator

Closing for now because it isn't super important or actionable. I guess we need to keep this in the back of our mind—feel free to reopen :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants