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

Fixes Typing errors for points at infinity (NoneTypes) #89

Merged
merged 4 commits into from
May 9, 2020

Conversation

CarlBeek
Copy link
Collaborator

What was wrong?

The point at infinity on any given curve is encoded as None. MyPy was not informed.

How was it fixed?

I told MyPy.

Cute Animal Picture

image

py_ecc/bls12_381/bls12_381_curve.py Outdated Show resolved Hide resolved
@@ -201,7 +201,7 @@ class FQP(object):

def __init__(self,
coeffs: Sequence[IntOrFQ],
modulus_coeffs: Sequence[IntOrFQ] = None) -> None:
modulus_coeffs: Sequence[IntOrFQ] = []) -> None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is to handle a separate error where len(modulus_coeffs) is called in line 208 below. This is not possible with None as it has no __len__. The reason for having a default argument here is for simple type(self) calls.

@@ -64,8 +65,8 @@
bls12_381_FQ2,
bls12_381_FQ12,
)
Point2D = Tuple[Field, Field]
Point3D = Tuple[Field, Field, Field]
Point2D = Optional[Tuple[Field, Field]] # Point at infinity is encoded as a None
Copy link
Collaborator Author

@CarlBeek CarlBeek Mar 30, 2020

Choose a reason for hiding this comment

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

This is the meat of this PR and addresses 48 type errors.

Side note, should extended type checking be a part of CI on this repo? I feel like it should.

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened issue #95 for this.

@hwwhww hwwhww merged commit 3d7d64f into ethereum:master May 9, 2020
@CarlBeek CarlBeek deleted the typing_fixes branch May 12, 2020 14:09
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