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

Configure ruff #88

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/nucypher-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,16 @@ jobs:
working-directory: nucypher-core-python

- name: Install pip dependencies
run: pip install mypy
run: pip install mypy ruff

- name: Run mypy.stubtest
run: python -m mypy.stubtest nucypher_core --allowlist stubtest-allowlist.txt
working-directory: nucypher-core-python

- name: Run ruff
run: ruff check nucypher_core
working-directory: nucypher-core-python

trigger-wheels:
runs-on: ubuntu-latest
needs: test
Expand Down
72 changes: 51 additions & 21 deletions nucypher-core-python/nucypher_core/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
from typing import List, Dict, Sequence, Optional, Mapping, Tuple, Set, final

from .umbral import (
SecretKey,
PublicKey,
Signer,
Capsule,
VerifiedKeyFrag,
VerifiedCapsuleFrag,
RecoverableSignature
)
from typing import Dict, List, Mapping, Optional, Sequence, Set, Tuple, final

from .ferveo import (
Ciphertext,
CiphertextHeader,
DkgPublicKey,
FerveoPublicKey,
FerveoVariant, SharedSecret,
FerveoVariant,
SharedSecret,
)
from .umbral import (
Capsule,
PublicKey,
RecoverableSignature,
SecretKey,
Signer,
VerifiedCapsuleFrag,
VerifiedKeyFrag,
)


@final
class Address:
Expand Down Expand Up @@ -235,7 +234,12 @@ class ReencryptionRequest:
@final
class ReencryptionResponse:

def __init__(self, signer: Signer, capsules_and_vcfrags: Sequence[Tuple[Capsule, VerifiedCapsuleFrag]]):
def __init__(
self,
signer: Signer,
capsules_and_vcfrags:
Sequence[Tuple[Capsule, VerifiedCapsuleFrag]]
):
...

def verify(
Expand Down Expand Up @@ -374,7 +378,11 @@ class NodeMetadata:
@final
class FleetStateChecksum:

def __init__(self, other_nodes: Sequence[NodeMetadata], this_node: Optional[NodeMetadata]):
def __init__(
self,
other_nodes: Sequence[NodeMetadata],
this_node: Optional[NodeMetadata]
):
...

def __bytes__(self) -> bytes:
Expand Down Expand Up @@ -452,7 +460,12 @@ class AuthenticatedData:
...


def encrypt_for_dkg(data: bytes, public_key: DkgPublicKey, conditions: Conditions) -> Tuple[Ciphertext, AuthenticatedData]:
def encrypt_for_dkg(
data: bytes,
public_key: DkgPublicKey,
conditions: Conditions
) -> Tuple[
Ciphertext, AuthenticatedData]:
...


Expand All @@ -478,6 +491,7 @@ class AccessControlPolicy:
def __bytes__(self) -> bytes:
...


@final
class ThresholdMessageKit:

Expand All @@ -502,7 +516,14 @@ class ThresholdMessageKit:
@final
class ThresholdDecryptionRequest:

def __init__(self, ritual_id: int, variant: FerveoVariant, ciphertext_header: CiphertextHeader, acp: AccessControlPolicy, context: Optional[Context]):
def __init__(
self,
ritual_id: int,
variant: FerveoVariant,
ciphertext_header: CiphertextHeader,
acp: AccessControlPolicy,
context: Optional[Context]
):
...

ritual_id: int
Expand All @@ -515,8 +536,11 @@ class ThresholdDecryptionRequest:

ciphertext_header: CiphertextHeader

def encrypt(self, shared_secret: SessionSharedSecret,
requester_public_key: SessionStaticKey) -> EncryptedThresholdDecryptionRequest:
def encrypt(
self,
shared_secret: SessionSharedSecret,
requester_public_key: SessionStaticKey
) -> EncryptedThresholdDecryptionRequest:
...

@staticmethod
Expand Down Expand Up @@ -557,7 +581,10 @@ class ThresholdDecryptionResponse:

ritual_id: int

def encrypt(self, shared_secret: SessionSharedSecret) -> EncryptedThresholdDecryptionResponse:
def encrypt(
self,
shared_secret: SessionSharedSecret
) -> EncryptedThresholdDecryptionResponse:
...

@staticmethod
Expand Down Expand Up @@ -612,7 +639,10 @@ class SessionStaticSecret:
def public_key(self) -> SessionStaticKey:
...

def derive_shared_secret(self, their_public_key: SessionStaticKey) -> SessionSharedSecret:
def derive_shared_secret(
self,
their_public_key: SessionStaticKey
) -> SessionSharedSecret:
...


Expand Down
6 changes: 4 additions & 2 deletions nucypher-core-python/nucypher_core/ferveo.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Sequence, final


@final
class Keypair:
@staticmethod
Expand Down Expand Up @@ -113,7 +112,10 @@ class Dkg:
def generate_transcript(self) -> Transcript:
...

def aggregate_transcripts(self, messages: Sequence[ValidatorMessage]) -> AggregatedTranscript:
def aggregate_transcripts(
self,
messages: Sequence[ValidatorMessage]
) -> AggregatedTranscript:
...


Expand Down
8 changes: 5 additions & 3 deletions nucypher-core-python/nucypher_core/umbral.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Optional, Tuple, List, final, Sequence

from typing import List, Optional, Tuple, final

@final
class SecretKey:
Expand Down Expand Up @@ -55,7 +54,10 @@ class PublicKey:
...

@staticmethod
def recover_from_prehash(prehash: bytes, signature: RecoverableSignature) -> PublicKey:
def recover_from_prehash(
prehash: bytes,
signature: RecoverableSignature
) -> PublicKey:
...


Expand Down
4 changes: 4 additions & 0 deletions nucypher-core-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]

[tool.ruff]
exclude = ["nucypher_core/__init__.py"] # false-positive unused-import
select = ["E", "F", "I"]
Loading