Skip to content

Commit

Permalink
ruff: apply new formatting rules
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeniy Zayats <[email protected]>
  • Loading branch information
Evgeniy Zayats committed May 3, 2024
1 parent 3ba69c4 commit b4055be
Show file tree
Hide file tree
Showing 99 changed files with 800 additions and 2,175 deletions.
8 changes: 2 additions & 6 deletions neofs-testlib/neofs_testlib/blockchain/role_designation.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def set_notary_nodes_multisig_tx(
) -> None:
keys = [f"bytes:{k}" for k in pubkeys]
keys_str = " ".join(keys)
multisig = Multisig(
self.neogo, invoke_tx_file=invoke_tx_file, block_period=self.block_period
)
multisig = Multisig(self.neogo, invoke_tx_file=invoke_tx_file, block_period=self.block_period)
multisig.create_and_send(
self.designate_contract,
f"designateAsRole int:32 [ {keys_str} ]",
Expand All @@ -128,9 +126,7 @@ def set_inner_ring_multisig_tx(
) -> None:
keys = [f"bytes:{k}" for k in pubkeys]
keys_str = " ".join(keys)
multisig = Multisig(
self.neogo, invoke_tx_file=invoke_tx_file, block_period=self.block_period
)
multisig = Multisig(self.neogo, invoke_tx_file=invoke_tx_file, block_period=self.block_period)
multisig.create_and_send(
self.designate_contract,
f"designateAsRole int:16 [ {keys_str} ]",
Expand Down
8 changes: 2 additions & 6 deletions neofs-testlib/neofs_testlib/blockchain/rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def invoke_function(
params: Optional[list] = None,
signers: Optional[list] = None,
) -> Dict[str, Any]:
return self._call_endpoint(
"invokefunction", params=[sc_hash, function, params or [], signers or []]
)
return self._call_endpoint("invokefunction", params=[sc_hash, function, params or [], signers or []])

def get_transaction_height(self, txid: str):
return self._call_endpoint("gettransactionheight", params=[txid])
Expand Down Expand Up @@ -69,9 +67,7 @@ def _call_endpoint(self, method, params=None) -> Dict[str, Any]:
return response.json()
except Exception as exc:
raise NeoRPCException(
f"Could not call method {method} "
f"with endpoint: {self.endpoint}: {exc}"
f"\nRequest sent: {payload}"
f"Could not call method {method} " f"with endpoint: {self.endpoint}: {exc}" f"\nRequest sent: {payload}"
) from exc


Expand Down
13 changes: 3 additions & 10 deletions neofs-testlib/neofs_testlib/cli/cli_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class CliCommand:

WALLET_SOURCE_ERROR_MSG = "Provide either wallet or wallet_config to specify wallet location"
WALLET_PASSWD_ERROR_MSG = "Provide either wallet_password or wallet_config to specify password"

Expand All @@ -27,9 +26,7 @@ class CliCommand:
def __init__(self, shell: Shell, cli_exec_path: str, **base_params):
self.shell = shell
self.cli_exec_path = cli_exec_path
self.__base_params = " ".join(
[f"--{param} {value}" for param, value in base_params.items() if value]
)
self.__base_params = " ".join([f"--{param} {value}" for param, value in base_params.items() if value])

def _format_command(self, command: str, **params) -> str:
param_str = []
Expand All @@ -51,9 +48,7 @@ def _format_command(self, command: str, **params) -> str:
val_str = str(value_item).replace("'", "\\'")
param_str.append(f"--{param} '{val_str}'")
elif isinstance(value, dict):
param_str.append(
f'--{param} \'{",".join(f"{key}={val}" for key, val in value.items())}\''
)
param_str.append(f'--{param} \'{",".join(f"{key}={val}" for key, val in value.items())}\'')
else:
if "'" in str(value):
value_str = str(value).replace('"', '\\"')
Expand All @@ -71,7 +66,5 @@ def _execute(self, command: Optional[str], **params) -> CommandResult:
def _execute_with_password(self, command: Optional[str], password, **params) -> CommandResult:
return self.shell.exec(
self._format_command(command, **params),
options=CommandOptions(
interactive_inputs=[InteractiveInput(prompt_pattern="assword", input=password)]
),
options=CommandOptions(interactive_inputs=[InteractiveInput(prompt_pattern="assword", input=password)]),
)
6 changes: 1 addition & 5 deletions neofs-testlib/neofs_testlib/cli/neofs_adm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ def init(self, path: str = "~/.neofs/adm/config.yml") -> CommandResult:
"""
return self._execute(
"config init",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)
84 changes: 14 additions & 70 deletions neofs-testlib/neofs_testlib/cli/neofs_adm/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ def deposit_notary(
"""
return self._execute(
"morph deposit-notary",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def dump_balances(
Expand All @@ -56,11 +52,7 @@ def dump_balances(
"""
return self._execute(
"morph dump-balances",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def dump_config(self, rpc_endpoint: str) -> CommandResult:
Expand All @@ -74,11 +66,7 @@ def dump_config(self, rpc_endpoint: str) -> CommandResult:
"""
return self._execute(
"morph dump-config",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def dump_containers(
Expand All @@ -101,11 +89,7 @@ def dump_containers(
"""
return self._execute(
"morph dump-containers",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def dump_hashes(self, rpc_endpoint: str, domain: str) -> CommandResult:
Expand All @@ -120,11 +104,7 @@ def dump_hashes(self, rpc_endpoint: str, domain: str) -> CommandResult:
"""
return self._execute(
"morph dump-hashes",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def force_new_epoch(
Expand All @@ -141,11 +121,7 @@ def force_new_epoch(
"""
return self._execute(
"morph force-new-epoch",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def generate_alphabet(
Expand All @@ -164,11 +140,7 @@ def generate_alphabet(
"""
return self._execute(
"morph generate-alphabet",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def generate_storage_wallet(
Expand All @@ -191,11 +163,7 @@ def generate_storage_wallet(
"""
return self._execute(
"morph generate-storage-wallet",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def init(
Expand Down Expand Up @@ -231,11 +199,7 @@ def init(
"""
return self._execute(
"morph init",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def refill_gas(
Expand All @@ -258,11 +222,7 @@ def refill_gas(
"""
return self._execute(
"morph refill-gas",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def restore_containers(
Expand All @@ -285,11 +245,7 @@ def restore_containers(
"""
return self._execute(
"morph restore-containers",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def set_policy(
Expand Down Expand Up @@ -347,11 +303,7 @@ def update_contracts(
"""
return self._execute(
"morph update-contracts",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def set_config(self, rpc_endpoint: str, alphabet_wallets: str, post_data: str) -> CommandResult:
Expand All @@ -367,11 +319,7 @@ def set_config(self, rpc_endpoint: str, alphabet_wallets: str, post_data: str) -
"""
return self._execute(
"morph set-config",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)

def deploy(
Expand All @@ -398,9 +346,5 @@ def deploy(
"""
return self._execute(
"morph deploy",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)
6 changes: 1 addition & 5 deletions neofs-testlib/neofs_testlib/cli/neofs_adm/storage_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ def set(self, account: str, wallet: str) -> CommandResult:
"""
return self._execute(
"storage-config",
**{
param: param_value
for param, param_value in locals().items()
if param not in ["self"]
},
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
)
Loading

0 comments on commit b4055be

Please sign in to comment.