-
Notifications
You must be signed in to change notification settings - Fork 10
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
Update Python typings #139
Conversation
Codecov Report
@@ Coverage Diff @@
## main #139 +/- ##
==========================================
- Coverage 78.48% 77.96% -0.52%
==========================================
Files 24 23 -1
Lines 4954 4979 +25
==========================================
- Hits 3888 3882 -6
- Misses 1066 1097 +31
|
ferveo-python/ferveo/__init__.pyi
Outdated
class DecryptionSharePrecomputed: | ||
@staticmethod | ||
def from_bytes(data: bytes) -> DecryptionSharePrecomputed: | ||
def from_bytes(bytes: bytes) -> DecryptionSharePrecomputed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made an identical comment in nucypher/nucypher-core#72, but I'd prefer to avoid name shadowing bytes()
throughout this changeset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will backport these changes to nucypher-core
(similar to any changes that may happen with rust_umbral
)
ferveo-python/ferveo/__init__.pyi
Outdated
) -> bytes: | ||
... | ||
|
||
|
||
def combine_decryption_shares_precomputed( | ||
decryption_shares: Sequence[DecryptionSharePrecomputed], | ||
shares: Sequence[DecryptionSharePrecomputed], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
ferveo-python/test/test_ferveo.py
Outdated
(1, FerveoVariant.simple), | ||
(4, FerveoVariant.simple), | ||
(8, FerveoVariant.simple), | ||
(32, FerveoVariant.simple), | ||
(1, FerveoVariant.precomputed), | ||
(4, FerveoVariant.precomputed), | ||
(8, FerveoVariant.precomputed), | ||
(32, FerveoVariant.precomputed), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's introduce some odd numbers to this parametrization, after it's supported (now?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
583b7e0
to
9bcce6a
Compare
9bcce6a
to
6c1d4be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👨🏻🚀
fn precomputed() -> &'static str { | ||
api::FerveoVariant::Precomputed.as_str() | ||
fn precomputed() -> FerveoVariant { | ||
api::FerveoVariant::Precomputed.into() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 - this seems much better than using strings.
assert FerveoVariant.simple() == "FerveoVariant::Simple" | ||
assert str(FerveoVariant.precomputed) == "FerveoVariant::Precomputed" | ||
assert str(FerveoVariant.simple) == "FerveoVariant::Simple" | ||
assert FerveoVariant.precomputed == FerveoVariant.precomputed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
c3b7497
to
922ae5a
Compare
pub fn precomputed() -> String { | ||
api::FerveoVariant::Precomputed.as_str().to_string() | ||
pub fn precomputed() -> FerveoVariant { | ||
FerveoVariant(api::FerveoVariant::Precomputed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸
922ae5a
to
cea467e
Compare
These changes are confirmed to be working upstream, so I'd be happy to merge this once nucypher/nucypher#3171 is reviewed |
ferveo-python/ferveo/__init__.pyi
Outdated
class FerveoVariant: | ||
@staticmethod | ||
def simple() -> str: ... | ||
simple: FerveoVariant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nitpick I didn't pick up on earlier (and I know it's annoying), but can these be SIMPLE
/PRECOMPUTED
or Simple
/Precomputed
. The lowercase looks a little weird in the Python code 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are class attributes, so I assumed they should be lowercase. I can fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. Admittedly, it's a nitpick so if it is easy to fix/makes sense then great; if not, then you can ignore.
I didn't notice it until I saw it used in the 3171.
Tested in nucypher/nucypher#3171 |
Type of PR:
Required reviews:
What this does:
mypy.stubtest
check to CIumbral-pre-python/example/example.py
on CIferveo_py
toferveo
modulematuring
for releasingmaturin.yml
CI workflowFerveoVariant
Python typeWhy it's needed:
Notes for reviewers:
ferveo
Python typings nucypher-core#71maturin
on the back of these changesmaturin
built modules are not recognized bymypy.stubtest
for some reasonrust-umbral
andnucypher-core
ferveo
Python package anyway; We'd rather use bindings exposed fromnucypher-core