Skip to content

Commit

Permalink
Implement B006 linting rule
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Feb 12, 2024
1 parent d31e6c0 commit 2eabdfa
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 156 deletions.
12 changes: 6 additions & 6 deletions aries_cloudagent/anoncreds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
):
"""Constructor."""
super().__init__(message, resolution_metadata)
self.resolution_metadata = resolution_metadata
self.resolution_metadata = resolution_metadata or {}


class AnonCredsRegistrationError(BaseAnonCredsError):
Expand Down Expand Up @@ -144,7 +144,7 @@ async def register_schema(
self,
profile: Profile,
schema: AnonCredsSchema,
options: dict = {},
options: Optional[dict] = None,
) -> SchemaResult:
"""Register a schema on the registry."""

Expand All @@ -154,7 +154,7 @@ async def register_credential_definition(
profile: Profile,
schema: GetSchemaResult,
credential_definition: CredDef,
options: dict = {},
options: Optional[dict] = None,
) -> CredDefResult:
"""Register a credential definition on the registry."""

Expand All @@ -163,7 +163,7 @@ async def register_revocation_registry_definition(
self,
profile: Profile,
revocation_registry_definition: RevRegDef,
options: dict = {},
options: Optional[dict] = None,
) -> RevRegDefResult:
"""Register a revocation registry definition on the registry."""

Expand All @@ -173,7 +173,7 @@ async def register_revocation_list(
profile: Profile,
rev_reg_def: RevRegDef,
rev_list: RevList,
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Register a revocation list on the registry."""

Expand All @@ -185,6 +185,6 @@ async def update_revocation_list(
prev_list: RevList,
curr_list: RevList,
revoked: Sequence[int],
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Update a revocation list on the registry."""
12 changes: 6 additions & 6 deletions aries_cloudagent/anoncreds/default/did_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
import re
from typing import Pattern, Sequence
from typing import Optional, Pattern, Sequence

from ....config.injection_context import InjectionContext
from ....core.profile import Profile
Expand Down Expand Up @@ -55,7 +55,7 @@ async def register_schema(
self,
profile: Profile,
schema: AnonCredsSchema,
options: dict = {},
options: Optional[dict] = None,
) -> SchemaResult:
"""Register a schema on the registry."""
raise NotImplementedError()
Expand All @@ -71,7 +71,7 @@ async def register_credential_definition(
profile: Profile,
schema: GetSchemaResult,
credential_definition: CredDef,
options: dict = {},
options: Optional[dict] = None,
) -> CredDefResult:
"""Register a credential definition on the registry."""
raise NotImplementedError()
Expand All @@ -86,7 +86,7 @@ async def register_revocation_registry_definition(
self,
profile: Profile,
revocation_registry_definition: RevRegDef,
options: dict = {},
options: Optional[dict] = None,
) -> RevRegDefResult:
"""Register a revocation registry definition on the registry."""
raise NotImplementedError()
Expand All @@ -102,7 +102,7 @@ async def register_revocation_list(
profile: Profile,
rev_reg_def: RevRegDef,
rev_list: RevList,
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Register a revocation list on the registry."""
raise NotImplementedError()
Expand All @@ -114,7 +114,7 @@ async def update_revocation_list(
prev_list: RevList,
curr_list: RevList,
revoked: Sequence[int],
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Update a revocation list on the registry."""
raise NotImplementedError()
12 changes: 6 additions & 6 deletions aries_cloudagent/anoncreds/default/did_web/registry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""DID Web Registry."""

import re
from typing import Pattern, Sequence
from typing import Optional, Pattern, Sequence

from ....config.injection_context import InjectionContext
from ....core.profile import Profile
Expand Down Expand Up @@ -50,7 +50,7 @@ async def register_schema(
self,
profile: Profile,
schema: AnonCredsSchema,
options: dict = {},
options: Optional[dict] = None,
) -> SchemaResult:
"""Register a schema on the registry."""
raise NotImplementedError()
Expand All @@ -66,7 +66,7 @@ async def register_credential_definition(
profile: Profile,
schema: GetSchemaResult,
credential_definition: CredDef,
options: dict = {},
options: Optional[dict] = None,
) -> CredDefResult:
"""Register a credential definition on the registry."""
raise NotImplementedError()
Expand All @@ -81,7 +81,7 @@ async def register_revocation_registry_definition(
self,
profile: Profile,
revocation_registry_definition: RevRegDef,
options: dict = {},
options: Optional[dict] = None,
) -> RevRegDefResult:
"""Register a revocation registry definition on the registry."""
raise NotImplementedError()
Expand All @@ -97,7 +97,7 @@ async def register_revocation_list(
profile: Profile,
rev_reg_def: RevRegDef,
rev_list: RevList,
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Register a revocation list on the registry."""
raise NotImplementedError()
Expand All @@ -109,7 +109,7 @@ async def update_revocation_list(
prev_list: RevList,
curr_list: RevList,
revoked: Sequence[int],
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Update a revocation list on the registry."""
raise NotImplementedError()
3 changes: 2 additions & 1 deletion aries_cloudagent/anoncreds/default/legacy_indy/author.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from aries_cloudagent.storage.error import StorageNotFoundError


async def get_endorser_info(profile, options: Optional[dict] = {}):
async def get_endorser_info(profile, options: Optional[dict] = None):
"""Gets the endorser did for the current transaction."""
options = options or {}
endorser_connection_id = options.get("endorser_connection_id", None)
if not endorser_connection_id:
endorser_connection_id = await get_endorser_connection_id(profile)
Expand Down
20 changes: 11 additions & 9 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import uuid
from asyncio import shield
from typing import List, Pattern, Sequence, Tuple
from typing import List, Optional, Pattern, Sequence, Tuple

from base58 import alphabet

Expand Down Expand Up @@ -198,10 +198,10 @@ async def register_schema(
self,
profile: Profile,
schema: AnonCredsSchema,
options: dict = {},
options: Optional[dict] = None,
) -> SchemaResult:
"""Register a schema on the registry."""

options = options or {}
schema_id = self.make_schema_id(schema)

# Assume endorser role on the network, no option for 3rd-party endorser
Expand Down Expand Up @@ -359,10 +359,10 @@ async def register_credential_definition(
profile: Profile,
schema: GetSchemaResult,
credential_definition: CredDef,
options: dict = {},
options: Optional[dict] = None,
) -> CredDefResult:
"""Register a credential definition on the registry."""

options = options or {}
cred_def_id = self.make_cred_def_id(schema, credential_definition)

ledger = profile.inject_or(BaseLedger)
Expand Down Expand Up @@ -547,9 +547,10 @@ async def register_revocation_registry_definition(
self,
profile: Profile,
revocation_registry_definition: RevRegDef,
options: dict = {},
options: Optional[dict] = None,
) -> RevRegDefResult:
"""Register a revocation registry definition on the registry."""
options = options or {}
rev_reg_def_id = self.make_rev_reg_def_id(revocation_registry_definition)

ledger = profile.inject(BaseLedger)
Expand Down Expand Up @@ -829,10 +830,10 @@ async def register_revocation_list(
profile: Profile,
rev_reg_def: RevRegDef,
rev_list: RevList,
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Register a revocation list on the registry."""

options = options or {}
rev_reg_entry = {"ver": "1.0", "value": {"accum": rev_list.current_accumulator}}

endorser_did = None
Expand Down Expand Up @@ -929,9 +930,10 @@ async def update_revocation_list(
prev_list: RevList,
curr_list: RevList,
revoked: Sequence[int],
options: dict = {},
options: Optional[dict] = None,
) -> RevListResult:
"""Update a revocation list."""
options = options or {}
newly_revoked_indices = list(revoked)
rev_reg_entry = {
"ver": "1.0",
Expand Down
8 changes: 4 additions & 4 deletions aries_cloudagent/anoncreds/events.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Events fired by AnonCreds interface."""

import re
from typing import NamedTuple
from typing import NamedTuple, Optional

from ..core.event_bus import Event
from .models.anoncreds_revocation import RevRegDef
Expand Down Expand Up @@ -52,7 +52,7 @@ def with_payload(
issuer_id: str,
support_revocation: bool,
max_cred_num: int,
options: dict = {},
options: Optional[dict] = None,
):
"""With payload."""
payload = CredDefFinishedPayload(
Expand Down Expand Up @@ -94,7 +94,7 @@ def with_payload(
cls,
rev_reg_def_id: str,
rev_reg_def: RevRegDef,
options: dict = {},
options: Optional[dict] = None,
):
"""With payload."""
payload = RevRegDefFinishedPayload(rev_reg_def_id, rev_reg_def, options)
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(self, payload: RevListFinishedPayload):
def with_payload(
cls,
rev_reg_def_id: str,
options: dict = {},
options: Optional[dict] = None,
):
"""With payload."""
payload = RevListFinishedPayload(rev_reg_def_id, options)
Expand Down
1 change: 1 addition & 0 deletions aries_cloudagent/anoncreds/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ async def get_credentials_for_presentation_request_by_referent(
*presentation_request["requested_attributes"],
*presentation_request["requested_predicates"],
)
extra_query = extra_query or {}

creds = {}

Expand Down
13 changes: 9 additions & 4 deletions aries_cloudagent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def create_and_register_schema(
name: str,
version: str,
attr_names: Sequence[str],
options: dict = {},
options: Optional[dict] = None,
) -> SchemaResult:
"""Create a new credential schema and store it in the wallet.
Expand All @@ -179,6 +179,7 @@ async def create_and_register_schema(
A SchemaResult instance
"""
options = options or {}
# Check if record of a similar schema already exists in our records
async with self.profile.session() as session:
# TODO scan?
Expand Down Expand Up @@ -287,7 +288,7 @@ async def create_and_register_credential_definition(
schema_id: str,
tag: Optional[str] = None,
signature_type: Optional[str] = None,
options: dict = {},
options: Optional[dict] = None,
) -> CredDefResult:
"""Create a new credential definition and store it in the wallet.
Expand All @@ -302,6 +303,7 @@ async def create_and_register_credential_definition(
CredDefResult: the result of the credential definition creation
"""
options = options or {}
support_revocation = options.get("support_revocation", False)
if not isinstance(support_revocation, bool):
raise ValueError("support_revocation must be a boolean")
Expand Down Expand Up @@ -360,9 +362,10 @@ async def store_credential_definition(
key_proof: KeyCorrectnessProof,
support_revocation: bool,
max_cred_num: int,
options: dict = {},
options: Optional[dict] = None,
):
"""Store the cred def and it's components in the wallet."""
options = options or {}
identifier = (
cred_def_result.job_id
or cred_def_result.credential_definition_state.credential_definition_id
Expand Down Expand Up @@ -415,7 +418,9 @@ async def store_credential_definition(
except AskarError as err:
raise AnonCredsIssuerError("Error storing credential definition") from err

async def finish_cred_def(self, job_id: str, cred_def_id: str, options: dict = {}):
async def finish_cred_def(
self, job_id: str, cred_def_id: str, options: Optional[dict] = None
):
"""Finish a cred def."""
async with self.profile.transaction() as txn:
entry = await self._finish_registration(
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudagent/anoncreds/models/anoncreds_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def __init__(
super().__init__(**kwargs)
self.job_id = job_id
self.schema_state = schema_state
self.registration_metadata = registration_metadata
self.schema_metadata = schema_metadata
self.registration_metadata = registration_metadata or {}
self.schema_metadata = schema_metadata or {}


class SchemaResultSchema(BaseModelSchema):
Expand Down
Loading

0 comments on commit 2eabdfa

Please sign in to comment.