Skip to content

Commit 355737b

Browse files
committed
refactor: replace Optional[type] with type | None
1 parent 7864fbe commit 355737b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+334
-364
lines changed

cardano_node_tests/cluster_management/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ClusterManagerCache:
1212
"""
1313

1414
# single `ClusterLib` instance can be used in multiple tests executed on the same worker
15-
cluster_obj: tp.Optional[clusterlib.ClusterLib] = None
15+
cluster_obj: clusterlib.ClusterLib | None = None
1616
# data for initialized cluster instance
1717
test_data: dict = dataclasses.field(default_factory=dict)
1818
addrs_data: dict = dataclasses.field(default_factory=dict)

cardano_node_tests/cluster_management/cluster_getter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _respin(self, start_cmd: str = "", stop_cmd: str = "") -> bool: # noqa: C90
184184
f"stop_cmd='{startup_files.stop_script}'"
185185
)
186186

187-
excp: tp.Optional[Exception] = None
187+
excp: Exception | None = None
188188
for i in range(2):
189189
if i > 0:
190190
self.log(

cardano_node_tests/cluster_management/manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def on_test_stop(self) -> None:
290290
def _get_resources_by_glob(
291291
self,
292292
glob: str,
293-
from_set: tp.Optional[tp.Iterable[str]] = None,
293+
from_set: tp.Iterable[str] | None = None,
294294
) -> list[str]:
295295
if from_set is not None and isinstance(from_set, str):
296296
msg = "`from_set` cannot be a string"
@@ -305,8 +305,8 @@ def _get_resources_by_glob(
305305

306306
def get_locked_resources(
307307
self,
308-
from_set: tp.Optional[tp.Iterable[str]] = None,
309-
worker_id: tp.Optional[str] = None,
308+
from_set: tp.Iterable[str] | None = None,
309+
worker_id: str | None = None,
310310
) -> list[str]:
311311
"""Get resources locked by worker.
312312
@@ -317,8 +317,8 @@ def get_locked_resources(
317317

318318
def get_used_resources(
319319
self,
320-
from_set: tp.Optional[tp.Iterable[str]] = None,
321-
worker_id: tp.Optional[str] = None,
320+
from_set: tp.Iterable[str] | None = None,
321+
worker_id: str | None = None,
322322
) -> list[str]:
323323
"""Get resources used by worker.
324324

cardano_node_tests/tests/delegation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def cluster_and_pool(
107107

108108
def db_check_delegation(
109109
pool_user: clusterlib.PoolUser | PoolUserScript,
110-
db_record: tp.Optional[dbsync_types.TxRecord],
110+
db_record: dbsync_types.TxRecord | None,
111111
deleg_epoch: int,
112112
pool_id: str,
113113
check_registration: bool = True,
@@ -128,9 +128,9 @@ def delegate_stake_addr(
128128
cluster_obj: clusterlib.ClusterLib,
129129
addrs_data: dict,
130130
temp_template: str,
131-
pool_user: tp.Optional[clusterlib.PoolUser] = None,
131+
pool_user: clusterlib.PoolUser | None = None,
132132
pool_id: str = "",
133-
cold_vkey: tp.Optional[pl.Path] = None,
133+
cold_vkey: pl.Path | None = None,
134134
amount: int = 100_000_000,
135135
use_build_cmd: bool = False,
136136
) -> DelegationOut:

cardano_node_tests/tests/kes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def check_kes_period_info_result( # noqa: C901
2828
kes_output: dict[str, tp.Any],
2929
expected_scenario: str,
3030
check_id: str,
31-
expected_start_kes: tp.Optional[int] = None,
32-
pool_num: tp.Optional[int] = None,
31+
expected_start_kes: int | None = None,
32+
pool_num: int | None = None,
3333
) -> list[str]:
3434
"""Check output `kes-period-info` command.
3535

cardano_node_tests/tests/plutus_common.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import dataclasses
22
import itertools
33
import pathlib as pl
4-
import typing as tp
54

65
import pytest
76
from cardano_clusterlib import clusterlib
@@ -469,13 +468,13 @@ class PlutusScriptData:
469468
@dataclasses.dataclass(frozen=True, order=True)
470469
class PlutusOp:
471470
script_file: clusterlib.FileType
472-
datum_file: tp.Optional[pl.Path] = None
473-
datum_cbor_file: tp.Optional[pl.Path] = None
474-
datum_value: tp.Optional[str] = None
475-
redeemer_file: tp.Optional[pl.Path] = None
476-
redeemer_cbor_file: tp.Optional[pl.Path] = None
477-
redeemer_value: tp.Optional[str] = None
478-
execution_cost: tp.Optional[ExecutionCost] = None
471+
datum_file: pl.Path | None = None
472+
datum_cbor_file: pl.Path | None = None
473+
datum_value: str | None = None
474+
redeemer_file: pl.Path | None = None
475+
redeemer_cbor_file: pl.Path | None = None
476+
redeemer_value: str | None = None
477+
execution_cost: ExecutionCost | None = None
479478

480479

481480
@dataclasses.dataclass(frozen=True, order=True)
@@ -734,7 +733,7 @@ def create_script_context_w_blockers(
734733
cluster_obj: clusterlib.ClusterLib,
735734
plutus_version: int,
736735
redeemer_file: pl.Path,
737-
tx_file: tp.Optional[pl.Path] = None,
736+
tx_file: pl.Path | None = None,
738737
) -> None:
739738
"""Run the `create-script-context` command (available in plutus-apps).
740739

cardano_node_tests/tests/test_chain_transactions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44
import pathlib as pl
55
import time
6-
import typing as tp
76

87
import allure
98
import pytest
@@ -50,7 +49,7 @@ def _gen_signed_tx(
5049
out_addr: clusterlib.AddressRecord,
5150
tx_name: str,
5251
fee: int,
53-
invalid_hereafter: tp.Optional[int] = None,
52+
invalid_hereafter: int | None = None,
5453
) -> tuple[clusterlib.UTXOData, clusterlib.TxRawOutput, pl.Path]:
5554
"""Generate Tx and return Tx output in a format that can be used as input for next Tx."""
5655
send_amount = txin.amount - fee

cardano_node_tests/tests/test_pools.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import json
1313
import logging
1414
import pathlib as pl
15-
import typing as tp
1615

1716
import allure
1817
import hypothesis
@@ -126,8 +125,8 @@ def _register_stake_pool_w_build(
126125
vrf_vkey_file: clusterlib.FileType,
127126
cold_key_pair: clusterlib.ColdKeyPair,
128127
tx_name: str,
129-
reward_account_vkey_file: tp.Optional[clusterlib.FileType] = None,
130-
deposit: tp.Optional[int] = None,
128+
reward_account_vkey_file: clusterlib.FileType | None = None,
129+
deposit: int | None = None,
131130
destination_dir: clusterlib.FileType = ".",
132131
) -> tuple[pl.Path, clusterlib.TxRawOutput]:
133132
"""Register a stake pool using a `transaction build` command.
@@ -335,7 +334,7 @@ def _create_register_pool(
335334
temp_dir: pl.Path,
336335
pool_owners: list[clusterlib.PoolUser],
337336
pool_data: clusterlib.PoolData,
338-
request: tp.Optional[FixtureRequest] = None,
337+
request: FixtureRequest | None = None,
339338
use_build_cmd: bool = False,
340339
) -> clusterlib.PoolCreationOutput:
341340
"""Create and register a stake pool.
@@ -402,7 +401,7 @@ def _create_register_pool_delegate_stake_tx(
402401
temp_template: str,
403402
temp_dir: pl.Path,
404403
pool_data: clusterlib.PoolData,
405-
request: tp.Optional[FixtureRequest] = None,
404+
request: FixtureRequest | None = None,
406405
use_build_cmd: bool = False,
407406
) -> clusterlib.PoolCreationOutput:
408407
"""Create and register a stake pool, delegate stake address - all in single TX.
@@ -532,7 +531,7 @@ def _create_register_pool_tx_delegate_stake_tx(
532531
temp_template: str,
533532
temp_dir: pl.Path,
534533
pool_data: clusterlib.PoolData,
535-
request: tp.Optional[FixtureRequest] = None,
534+
request: FixtureRequest | None = None,
536535
use_build_cmd: bool = False,
537536
) -> clusterlib.PoolCreationOutput:
538537
"""Create and register a stake pool - first TX; delegate stake address - second TX.

cardano_node_tests/tests/test_reconnect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def node_query_utxo(
7272
cluster_obj: clusterlib.ClusterLib,
7373
node: str,
7474
address: str = "",
75-
tx_raw_output: tp.Optional[clusterlib.TxRawOutput] = None,
75+
tx_raw_output: clusterlib.TxRawOutput | None = None,
7676
) -> list[clusterlib.UTXOData]:
7777
"""Query UTxO on given node."""
7878
orig_socket = os.environ.get("CARDANO_NODE_SOCKET_PATH")

cardano_node_tests/tests/test_rollback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pathlib as pl
1010
import shutil
1111
import time
12-
import typing as tp
1312

1413
import allure
1514
import pytest
@@ -137,7 +136,7 @@ def node_query_utxo(
137136
cluster_obj: clusterlib.ClusterLib,
138137
node: str,
139138
address: str = "",
140-
tx_raw_output: tp.Optional[clusterlib.TxRawOutput] = None,
139+
tx_raw_output: clusterlib.TxRawOutput | None = None,
141140
) -> list[clusterlib.UTXOData]:
142141
"""Query UTxO on given node."""
143142
orig_socket = os.environ.get("CARDANO_NODE_SOCKET_PATH")

0 commit comments

Comments
 (0)