Skip to content

Commit

Permalink
Update black and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls committed Mar 18, 2023
1 parent 8f17630 commit a065bce
Show file tree
Hide file tree
Showing 17 changed files with 695 additions and 734 deletions.
1 change: 0 additions & 1 deletion integration-test/test/test_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class TestDelegation(TestBase):
@retry(tries=TEST_RETRIES, backoff=1.5, delay=6, jitter=(0, 4))
def test_stake_delegation(self):

address = Address(
self.payment_key_pair.verification_key.hash(),
self.stake_key_pair.verification_key.hash(),
Expand Down
4 changes: 0 additions & 4 deletions integration-test/test/test_plutus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
class TestPlutus(TestBase):
@retry(tries=TEST_RETRIES, backoff=1.5, delay=6, jitter=(0, 4))
def test_plutus_v1(self):

# ----------- Giver give ---------------

with open("./plutus_scripts/fortytwo.plutus", "r") as f:
Expand Down Expand Up @@ -97,7 +96,6 @@ def test_plutus_v1(self):
@retry(tries=TEST_RETRIES, backoff=1.5, delay=6, jitter=(0, 4))
@pytest.mark.post_alonzo
def test_plutus_v2_datum_hash(self):

# ----------- Giver give ---------------

with open("./plutus_scripts/fortytwoV2.plutus", "r") as f:
Expand Down Expand Up @@ -173,7 +171,6 @@ def test_plutus_v2_datum_hash(self):
@retry(tries=TEST_RETRIES, backoff=1.5, delay=6, jitter=(0, 4))
@pytest.mark.post_alonzo
def test_plutus_v2_inline_script_inline_datum(self):

# ----------- Giver give ---------------

with open("./plutus_scripts/fortytwoV2.plutus", "r") as f:
Expand Down Expand Up @@ -237,7 +234,6 @@ def test_plutus_v2_inline_script_inline_datum(self):
@retry(tries=TEST_RETRIES, backoff=1.5, delay=6, jitter=(0, 4))
@pytest.mark.post_alonzo
def test_plutus_v2_ref_script(self):

# ----------- Create a reference script ---------------

with open("./plutus_scripts/fortytwoV2.plutus", "r") as f:
Expand Down
1,387 changes: 692 additions & 695 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions pycardano/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

@dataclass(repr=False)
class StakeCredential(ArrayCBORSerializable):

_CODE: Optional[int] = field(init=False, default=None)

credential: Union[VerificationKeyHash, ScriptHash]
Expand All @@ -29,23 +28,20 @@ def __post_init__(self):

@dataclass(repr=False)
class StakeRegistration(ArrayCBORSerializable):

_CODE: int = field(init=False, default=0)

stake_credential: StakeCredential


@dataclass(repr=False)
class StakeDeregistration(ArrayCBORSerializable):

_CODE: int = field(init=False, default=1)

stake_credential: StakeCredential


@dataclass(repr=False)
class StakeDelegation(ArrayCBORSerializable):

_CODE: int = field(init=False, default=2)

stake_credential: StakeCredential
Expand Down
1 change: 0 additions & 1 deletion pycardano/cip/cip8.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def verify(

# generate/extract the cose key
if not attach_cose_key:

# get the verification key from the headers
verification_key = decoded_message.phdr[KID]

Expand Down
1 change: 0 additions & 1 deletion pycardano/coinselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def select(
include_max_fee: Optional[bool] = True,
respect_min_utxo: Optional[bool] = True,
) -> Tuple[List[UTxO], Value]:

available: List[UTxO] = sorted(utxos, key=lambda utxo: utxo.output.lovelace)
max_fee = max_tx_fee(context) if include_max_fee else 0
total_requested = Value(max_fee)
Expand Down
1 change: 0 additions & 1 deletion pycardano/plutus.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,6 @@ def from_json(cls: Type[PlutusData], data: str) -> PlutusData:

@dataclass
class RawPlutusData(CBORSerializable):

data: CBORTag

def to_primitive(self) -> CBORTag:
Expand Down
4 changes: 0 additions & 4 deletions pycardano/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def to_shallow_primitive(self):

@dataclass(repr=False)
class _Script(ArrayCBORSerializable):

_TYPE: int = field(init=False, default=0)

script: Union[NativeScript, PlutusV1Script, PlutusV2Script]
Expand All @@ -293,7 +292,6 @@ def from_primitive(cls: Type[_Script], values: List[Primitive]) -> _Script:

@dataclass(repr=False)
class _DatumOption(ArrayCBORSerializable):

_TYPE: int = field(init=False, default=0)

datum: Union[DatumHash, Any]
Expand Down Expand Up @@ -329,7 +327,6 @@ def from_primitive(

@dataclass(repr=False)
class _ScriptRef(CBORSerializable):

script: _Script

def to_primitive(self) -> Primitive:
Expand Down Expand Up @@ -374,7 +371,6 @@ class _TransactionOutputLegacy(ArrayCBORSerializable):

@dataclass(repr=False)
class TransactionOutput(CBORSerializable):

address: Address

amount: Union[Value]
Expand Down
7 changes: 1 addition & 6 deletions pycardano/txbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,8 @@ def _merge_changes(changes):
self._outputs += changes

if change_address:

if merge_change:

for idx, output in enumerate(original_outputs):

# Find any transaction outputs which already contain the change address
if change_address == output.address:
if change_output_index is None or output.lovelace == 0:
Expand Down Expand Up @@ -607,7 +604,7 @@ def _pack_tokens_for_change(
output = TransactionOutput(change_address, base_coin)

# iteratively add tokens to output
for (policy_id, assets) in change_estimator.multi_asset.items():
for policy_id, assets in change_estimator.multi_asset.items():
temp_multi_asset = MultiAsset()
temp_value = Value(coin=0)
temp_assets = Asset()
Expand Down Expand Up @@ -673,7 +670,6 @@ def _input_vkey_hashes(self) -> Set[VerificationKeyHash]:
return results

def _certificate_vkey_hashes(self) -> Set[VerificationKeyHash]:

results = set()

def _check_and_add_vkey(stake_credential: StakeCredential):
Expand All @@ -697,7 +693,6 @@ def _get_total_key_deposit(self):
return self.context.protocol_param.key_deposit * len(results)

def _withdrawal_vkey_hashes(self) -> Set[VerificationKeyHash]:

results = set()

if self.withdrawals:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ pytest = "^7.2.1"
pytest-cov = "^4.0.0"
flake8 = "^5.0.4"
isort = "^5.11.4"
black = "^22.3.0"
black = "^23.1.0"
sphinx-copybutton = "^0.5.0"
retry = "^0.9.2"
Flask = "^2.0.3"
pytest-xdist = "^3.0.2"
mypy = "^0.991"
mypy = "^1.0.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
1 change: 0 additions & 1 deletion test/pycardano/backend/test_ogmios.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def test_genesis(self):
)

def test_utxo(self):

results = self.chain_context.utxos(
"addr_test1qraen6hr9zs5yae8cxnhlkh7rk2nfl7rnpg0xvmel3a0xf70v3kz6ee7mtq86x6gmrnw8j7kuf485902akkr7tlcx24qemz34a"
)
Expand Down
7 changes: 0 additions & 7 deletions test/pycardano/test_cip8.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@


def test_verify_message():

signed_message = "845869a3012704582060545b786d3a6f903158e35aae9b86548a99bc47d4b0a6f503ab5e78c1a9bbfc6761646472657373583900ddba3ad76313825f4f646f5aa6d323706653bda40ec1ae55582986a463e661768b92deba45b5ada4ab9e7ffd17ed3051b2e03500e0542e9aa166686173686564f452507963617264616e6f20697320636f6f6c2e58403b09cbae8d272ff94befd28cc04b152aea3c1633caffb4924a8a8c45be3ba6332a76d9f2aba833df53803286d32a5ee700990b79a0e86fab3cccdbfd37ce250f"

verification = verify(signed_message)
Expand All @@ -54,7 +53,6 @@ def test_verify_message():


def test_verify_message_cose_key_attached():

signed_message = {
"signature": "845846a201276761646472657373583900ddba3ad76313825f4f646f5aa6d323706653bda40ec1ae55582986a463e661768b92deba45b5ada4ab9e7ffd17ed3051b2e03500e0542e9aa166686173686564f452507963617264616e6f20697320636f6f6c2e584040b65c973ba6e123f1e7f738205b10c709fe214a27d21b1c382e6dfa5772aaeeb6222943fd56b1dd6bfa5abfa4a4992d2abde110cbd0c8651fdfa679ba462605",
"key": "a401010327200621582060545b786d3a6f903158e35aae9b86548a99bc47d4b0a6f503ab5e78c1a9bbfc",
Expand Down Expand Up @@ -85,7 +83,6 @@ def test_verify_message_stake_address():


def test_sign_message():

message = "Pycardano is cool."
signed_message = sign(
message, signing_key=SK, attach_cose_key=False, network=Network.TESTNET
Expand All @@ -97,7 +94,6 @@ def test_sign_message():


def test_sign_message_with_stake():

message = "Pycardano is cool."
signed_message = sign(
message, signing_key=STAKE_SK, attach_cose_key=False, network=Network.TESTNET
Expand All @@ -109,7 +105,6 @@ def test_sign_message_with_stake():


def test_sign_message_cosy_key_separate():

message = "Pycardano is cool."
signed_message = sign(
message, signing_key=SK, attach_cose_key=True, network=Network.TESTNET
Expand All @@ -121,7 +116,6 @@ def test_sign_message_cosy_key_separate():


def test_sign_and_verify():

# try first with no cose key attached
message = "Pycardano is cool."
signed_message = sign(
Expand All @@ -145,7 +139,6 @@ def test_sign_and_verify():


def test_sign_and_verify_stake():

# try first with no cose key attached
message = "Pycardano is cool."
signed_message = sign(
Expand Down
1 change: 0 additions & 1 deletion test/pycardano/test_coinselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def assert_request_fulfilled(request: List[TransactionOutput], selected: List[UT


class TestLargestFirst:

selector = LargestFirstSelector()

def test_ada_only(self, chain_context):
Expand Down
2 changes: 0 additions & 2 deletions test/pycardano/test_nativescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def test_full_tx():


def test_to_dict():

vk1 = VerificationKey.from_cbor(
"58206443a101bdb948366fc87369336224595d36d8b0eee5602cba8b81a024e58473"
)
Expand Down Expand Up @@ -169,7 +168,6 @@ def test_from_primitive_invalid_primitive_input():


def test_from_dict():

vk1 = VerificationKey.from_cbor(
"58206443a101bdb948366fc87369336224595d36d8b0eee5602cba8b81a024e58473"
)
Expand Down
2 changes: 0 additions & 2 deletions test/pycardano/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class MyTestDict(DictCBORSerializable):


def test_dict_cbor_serializable():

a = MyTestDict()
a[b"110"] = 1
a[b"100"] = 2
Expand All @@ -137,7 +136,6 @@ def test_dict_cbor_serializable():


def test_indefinite_list():

a = IndefiniteList([4, 5])

a.append(6)
Expand Down
1 change: 0 additions & 1 deletion test/pycardano/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def test_min_lovelace_ada_only_2(chain_context):


class TestMinLoveLaceMultiAsset:

# Tests copied from: https://github.com/input-output-hk/cardano-ledger/blob/master/doc/explanations/min-utxo-alonzo.rst#example-min-ada-value-calculations-and-current-constants

def test_min_lovelace_multi_asset_1(self, chain_context):
Expand Down
1 change: 0 additions & 1 deletion test/pycardano/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def check_two_way_cbor(serializable: CBORSerializable):


class FixedChainContext(ChainContext):

_protocol_param = ProtocolParameters(
min_fee_constant=155381,
min_fee_coefficient=44,
Expand Down

0 comments on commit a065bce

Please sign in to comment.