diff --git a/bindings/python/iota_sdk/types/address.py b/bindings/python/iota_sdk/types/address.py index bced975909..c6ab403d0b 100644 --- a/bindings/python/iota_sdk/types/address.py +++ b/bindings/python/iota_sdk/types/address.py @@ -81,21 +81,21 @@ class AddressWithUnspentOutputs(): output_ids: bool -def address_from_dict(dict: Dict[str, Any]) -> Union[Ed25519Address, AccountAddress, NFTAddress]: +def address_from_dict(d: Dict[str, Any]) -> Union[Ed25519Address, AccountAddress, NFTAddress]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == AddressType.ED25519: - return Ed25519Address.from_dict(dict) - if type == AddressType.ACCOUNT: - return AccountAddress.from_dict(dict) - if type == AddressType.NFT: - return NFTAddress.from_dict(dict) - raise Exception(f'invalid address type: {type}') + address_type = d['type'] + if address_type == AddressType.ED25519: + return Ed25519Address.from_dict(d) + if address_type == AddressType.ACCOUNT: + return AccountAddress.from_dict(d) + if address_type == AddressType.NFT: + return NFTAddress.from_dict(d) + raise Exception(f'invalid address type: {address_type}') def addresses_from_dicts( diff --git a/bindings/python/iota_sdk/types/context_input.py b/bindings/python/iota_sdk/types/context_input.py index a04964b0ae..5c1fce5925 100644 --- a/bindings/python/iota_sdk/types/context_input.py +++ b/bindings/python/iota_sdk/types/context_input.py @@ -73,22 +73,22 @@ class RewardContextInput(ContextInput): init=False) -def context_input_from_dict(dict: Dict[str, Any]) -> Union[CommitmentContextInput, - BlockIssuanceCreditContextInput, RewardContextInput]: +def context_input_from_dict(d: Dict[str, Any]) -> Union[CommitmentContextInput, + BlockIssuanceCreditContextInput, RewardContextInput]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == ContextInputType.Commitment: - return CommitmentContextInput.from_dict(dict) - if type == ContextInputType.BlockIssuanceCredit: - return BlockIssuanceCreditContextInput.from_dict(dict) - if type == ContextInputType.Reward: - return RewardContextInput.from_dict(dict) - raise Exception(f'invalid context input type: {type}') + context_input_type = dict['type'] + if context_input_type == ContextInputType.Commitment: + return CommitmentContextInput.from_dict(d) + if context_input_type == ContextInputType.BlockIssuanceCredit: + return BlockIssuanceCreditContextInput.from_dict(d) + if context_input_type == ContextInputType.Reward: + return RewardContextInput.from_dict(d) + raise Exception(f'invalid context input type: {context_input_type}') def context_inputs_from_dicts( diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index 2cd0d6874f..1da454e340 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -135,28 +135,28 @@ class StakingFeature(Feature): init=False) -def feature_from_dict(dict: Dict[str, Any]) -> Union[SenderFeature, IssuerFeature, - MetadataFeature, TagFeature, BlockIssuerFeature, StakingFeature]: +def feature_from_dict(d: Dict[str, Any]) -> Union[SenderFeature, IssuerFeature, + MetadataFeature, TagFeature, BlockIssuerFeature, StakingFeature]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == FeatureType.Sender: - return SenderFeature.from_dict(dict) - if type == FeatureType.Issuer: - return IssuerFeature.from_dict(dict) - if type == FeatureType.Metadata: - return MetadataFeature.from_dict(dict) - if type == FeatureType.Tag: - return TagFeature.from_dict(dict) - if type == FeatureType.BlockIssuer: - return BlockIssuerFeature.from_dict(dict) - if type == FeatureType.Staking: - return StakingFeature.from_dict(dict) - raise Exception(f'invalid feature type: {type}') + feature_type = d['type'] + if feature_type == FeatureType.Sender: + return SenderFeature.from_dict(d) + if feature_type == FeatureType.Issuer: + return IssuerFeature.from_dict(d) + if feature_type == FeatureType.Metadata: + return MetadataFeature.from_dict(d) + if feature_type == FeatureType.Tag: + return TagFeature.from_dict(d) + if feature_type == FeatureType.BlockIssuer: + return BlockIssuerFeature.from_dict(d) + if feature_type == FeatureType.Staking: + return StakingFeature.from_dict(d) + raise Exception(f'invalid feature type: {feature_type}') def features_from_dicts(dicts: List[Dict[str, Any]]) -> List[Union[SenderFeature, diff --git a/bindings/python/iota_sdk/types/output.py b/bindings/python/iota_sdk/types/output.py index f4227133b2..4ba6c77059 100644 --- a/bindings/python/iota_sdk/types/output.py +++ b/bindings/python/iota_sdk/types/output.py @@ -2,10 +2,10 @@ # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations -from dataclasses import dataclass, field -from dataclasses_json import config from enum import IntEnum from typing import Dict, Optional, List, Union, Any +from dataclasses import dataclass, field +from dataclasses_json import config from iota_sdk.types.common import HexStr, json from iota_sdk.types.feature import features_from_dicts, SenderFeature, IssuerFeature, MetadataFeature, TagFeature from iota_sdk.types.native_token import NativeToken @@ -227,26 +227,26 @@ class DelegationOutput(Output): OutputType.Delegation), init=False) -def output_from_dict(dict: Dict[str, Any]) -> Union[BasicOutput, AccountOutput, - FoundryOutput, NftOutput, DelegationOutput]: +def output_from_dict(d: Dict[str, Any]) -> Union[BasicOutput, AccountOutput, + FoundryOutput, NftOutput, DelegationOutput]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == OutputType.Basic: - return BasicOutput.from_dict(dict) - if type == OutputType.Account: - return AccountOutput.from_dict(dict) - if type == OutputType.Foundry: - return FoundryOutput.from_dict(dict) - if type == OutputType.Nft: - return NftOutput.from_dict(dict) - if type == OutputType.Delegation: - return DelegationOutput.from_dict(dict) - raise Exception(f'invalid output type: {type}') + output_type = dict['type'] + if output_type == OutputType.Basic: + return BasicOutput.from_dict(d) + if output_type == OutputType.Account: + return AccountOutput.from_dict(d) + if output_type == OutputType.Foundry: + return FoundryOutput.from_dict(d) + if output_type == OutputType.Nft: + return NftOutput.from_dict(d) + if output_type == OutputType.Delegation: + return DelegationOutput.from_dict(d) + raise Exception(f'invalid output type: {output_type}') def outputs_from_dicts(dicts: List[Dict[str, Any]]) -> List[Union[BasicOutput, diff --git a/bindings/python/iota_sdk/types/output_metadata.py b/bindings/python/iota_sdk/types/output_metadata.py index 06d91b0f0d..f85c988e80 100644 --- a/bindings/python/iota_sdk/types/output_metadata.py +++ b/bindings/python/iota_sdk/types/output_metadata.py @@ -2,9 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations +from typing import Dict, Optional, Union from dataclasses import dataclass, field from dataclasses_json import config -from typing import Dict, Optional, Union from iota_sdk.types.common import HexStr, json from iota_sdk.types.output import AccountOutput, BasicOutput, DelegationOutput, FoundryOutput, NftOutput, outputs_from_dicts @@ -67,9 +67,9 @@ def from_dict(cls, data_dict: Dict) -> OutputWithMetadata: def as_dict(self): """Returns a dictionary representation of OutputWithMetadata, with the fields metadata and output. """ - config = {} + d = {} - config['metadata'] = self.metadata.__dict__ - config['output'] = self.output.as_dict() + d['metadata'] = self.metadata.__dict__ + d['output'] = self.output.as_dict() - return config + return d diff --git a/bindings/python/iota_sdk/types/payload.py b/bindings/python/iota_sdk/types/payload.py index 3e5e3b68ed..8fb8c77d6e 100644 --- a/bindings/python/iota_sdk/types/payload.py +++ b/bindings/python/iota_sdk/types/payload.py @@ -65,19 +65,19 @@ class TransactionPayload(Payload): init=False) -def payload_from_dict(dict: Dict[str, Any]) -> Union[TaggedDataPayload, TransactionPayload]: +def payload_from_dict(d: Dict[str, Any]) -> Union[TaggedDataPayload, TransactionPayload]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == PayloadType.TaggedData: - return TaggedDataPayload.from_dict(dict) - if type == PayloadType.Transaction: - return TransactionPayload.from_dict(dict) - raise Exception(f'invalid payload type: {type}') + payload_type = d['type'] + if payload_type == PayloadType.TaggedData: + return TaggedDataPayload.from_dict(d) + if payload_type == PayloadType.Transaction: + return TransactionPayload.from_dict(d) + raise Exception(f'invalid payload type: {payload_type}') def payloads_from_dicts( diff --git a/bindings/python/iota_sdk/types/unlock.py b/bindings/python/iota_sdk/types/unlock.py index b4b3aa1527..9df8f505ba 100644 --- a/bindings/python/iota_sdk/types/unlock.py +++ b/bindings/python/iota_sdk/types/unlock.py @@ -77,23 +77,23 @@ class NftUnlock: type: int = field(default_factory=lambda: int(UnlockType.Nft), init=False) -def unlock_from_dict(dict: Dict[str, Any]) -> Union[SignatureUnlock, ReferenceUnlock, AccountUnlock, NftUnlock]: +def unlock_from_dict(d: Dict[str, Any]) -> Union[SignatureUnlock, ReferenceUnlock, AccountUnlock, NftUnlock]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == UnlockType.Signature: - return SignatureUnlock.from_dict(dict) - if type == UnlockType.Reference: - return ReferenceUnlock.from_dict(dict) - if type == UnlockType.Account: - return AccountUnlock.from_dict(dict) - if type == UnlockType.Nft: - return NftUnlock.from_dict(dict) - raise Exception(f'invalid unlock type: {type}') + unlock_type = d['type'] + if unlock_type == UnlockType.Signature: + return SignatureUnlock.from_dict(d) + if unlock_type == UnlockType.Reference: + return ReferenceUnlock.from_dict(d) + if unlock_type == UnlockType.Account: + return AccountUnlock.from_dict(d) + if unlock_type == UnlockType.Nft: + return NftUnlock.from_dict(d) + raise Exception(f'invalid unlock type: {unlock_type}') def unlocks_from_dicts(dicts: List[Dict[str, Any]]) -> List[Union[SignatureUnlock, diff --git a/bindings/python/iota_sdk/types/unlock_condition.py b/bindings/python/iota_sdk/types/unlock_condition.py index 556d9ab3fe..5faf8881de 100644 --- a/bindings/python/iota_sdk/types/unlock_condition.py +++ b/bindings/python/iota_sdk/types/unlock_condition.py @@ -149,30 +149,31 @@ class ImmutableAccountAddressUnlockCondition(UnlockCondition): UnlockConditionType.ImmutableAccountAddress), init=False) -def unlock_condition_from_dict(dict: Dict[str, Any]) -> Union[AddressUnlockCondition, StorageDepositReturnUnlockCondition, TimelockUnlockCondition, - ExpirationUnlockCondition, StateControllerAddressUnlockCondition, GovernorAddressUnlockCondition, ImmutableAccountAddressUnlockCondition]: +def unlock_condition_from_dict(d: Dict[str, Any]) -> Union[AddressUnlockCondition, StorageDepositReturnUnlockCondition, TimelockUnlockCondition, + ExpirationUnlockCondition, StateControllerAddressUnlockCondition, GovernorAddressUnlockCondition, ImmutableAccountAddressUnlockCondition]: """ Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. Arguments: - * `dict`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. """ - type = dict['type'] - if type == UnlockConditionType.Address: - return AddressUnlockCondition.from_dict(dict) - if type == UnlockConditionType.StorageDepositReturn: - return StorageDepositReturnUnlockCondition.from_dict(dict) - if type == UnlockConditionType.Timelock: - return TimelockUnlockCondition.from_dict(dict) - if type == UnlockConditionType.Expiration: - return ExpirationUnlockCondition.from_dict(dict) - if type == UnlockConditionType.StateControllerAddress: - return StateControllerAddressUnlockCondition.from_dict(dict) - if type == UnlockConditionType.GovernorAddress: - return GovernorAddressUnlockCondition.from_dict(dict) - if type == UnlockConditionType.ImmutableAccountAddress: - return ImmutableAccountAddressUnlockCondition.from_dict(dict) - raise Exception(f'invalid unlock condition type: {type}') + # pylint: disable=R0911 + uc_type = d['type'] + if uc_type == UnlockConditionType.Address: + return AddressUnlockCondition.from_dict(d) + if uc_type == UnlockConditionType.StorageDepositReturn: + return StorageDepositReturnUnlockCondition.from_dict(d) + if uc_type == UnlockConditionType.Timelock: + return TimelockUnlockCondition.from_dict(d) + if uc_type == UnlockConditionType.Expiration: + return ExpirationUnlockCondition.from_dict(d) + if uc_type == UnlockConditionType.StateControllerAddress: + return StateControllerAddressUnlockCondition.from_dict(d) + if uc_type == UnlockConditionType.GovernorAddress: + return GovernorAddressUnlockCondition.from_dict(d) + if uc_type == UnlockConditionType.ImmutableAccountAddress: + return ImmutableAccountAddressUnlockCondition.from_dict(d) + raise Exception(f'invalid unlock condition type: {uc_type}') def unlock_conditions_from_dicts(dicts: List[Dict[str, Any]]) -> List[Union[AddressUnlockCondition, StorageDepositReturnUnlockCondition, TimelockUnlockCondition,