Skip to content

Conversation

@EliRibble
Copy link

Python 2 was sunset in 2020, so it's worthwhile to remove compatibility shims now.

Type hinting information is quite helpful for anyone hoping to learn by reading the code.

Python 2 is deprecated.
This isn't required in Python 3.
We no longer support Python 2, it's over.
It makes it easier to declare the type signatures without having to resort to
using strings since the class is defined later.
Python 2 is well and truly gone.
We still have a variety of typing errors, but this at least gives us something
to target based on the behavior of the unit tests.
I don't know if this is mathematically correct, but I'm not sure why the code
is returning a new Inf rather than self. I'll leave it for now.
We manually specify the expected types for addend and result since they
may take either Point or Inf.

Also de-indent by raising an exception earlien for clarity.
This one is a bit tricky. We need to provide clear paths where the mypy engine
can eliminate the potential to have None types. This means creating a somewhat
clunky conditional for setting up the member variables and raising exceptions
in a few different places.
This requires explicitly checking for None so that mypy can detect that the
Optional has been resolved and we no longer have uncertain types. This does
somewhat damage the readability of X.can_sign, so the double check is left
in at a slight performance penalty.

I also renamed the "keypair" parameter as I find it more clearly readable
instead of having to realize that self.keypair and keypair are different.

Also avoid the Union type in return by catching and raising on the Inf case.
This may not be strictly correct.
Without this we may have an Inf type, which we really shouldn't ever get.
The big change here is that we now make the known curves into typed data
structures instead of just nested mappings.

This represents a change in the public API.
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.

1 participant