Skip to content

Commit b994c79

Browse files
Andres D. Molins1yam
authored andcommitted
Fix: Solved code-quality issue.
1 parent c52f9dc commit b994c79

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

src/aleph_client/commands/aggregate.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from aleph.sdk.account import _load_account
1212
from aleph.sdk.client import AuthenticatedAlephHttpClient
1313
from aleph.sdk.conf import settings
14-
from aleph.sdk.types import AccountFromPrivateKey
1514
from aleph.sdk.utils import extended_json_encoder
1615
from aleph_message.models import Chain, MessageType
1716
from aleph_message.status import MessageStatus
@@ -59,7 +58,7 @@ async def forget(
5958

6059
setup_logging(debug)
6160

62-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
61+
account = _load_account(private_key, private_key_file)
6362
address = account.get_address() if address is None else address
6463

6564
if key == "security" and not is_same_context():
@@ -132,7 +131,7 @@ async def post(
132131

133132
setup_logging(debug)
134133

135-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
134+
account = _load_account(private_key, private_key_file)
136135
address = account.get_address() if address is None else address
137136

138137
if key == "security" and not is_same_context():
@@ -194,7 +193,7 @@ async def get(
194193

195194
setup_logging(debug)
196195

197-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
196+
account = _load_account(private_key, private_key_file)
198197
address = account.get_address() if address is None else address
199198

200199
async with AuthenticatedAlephHttpClient(account=account, api_server=settings.API_HOST) as client:
@@ -230,7 +229,7 @@ async def list_aggregates(
230229

231230
setup_logging(debug)
232231

233-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
232+
account = _load_account(private_key, private_key_file)
234233
address = account.get_address() if address is None else address
235234

236235
aggr_link = f"{sanitize_url(settings.API_HOST)}/api/v0/aggregates/{address}.json"
@@ -304,7 +303,7 @@ async def authorize(
304303

305304
setup_logging(debug)
306305

307-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
306+
account = _load_account(private_key, private_key_file)
308307

309308
data = await get(
310309
key="security",
@@ -378,7 +377,7 @@ async def revoke(
378377

379378
setup_logging(debug)
380379

381-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
380+
account = _load_account(private_key, private_key_file)
382381

383382
data = await get(
384383
key="security",
@@ -433,7 +432,7 @@ async def permissions(
433432

434433
setup_logging(debug)
435434

436-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
435+
account = _load_account(private_key, private_key_file)
437436
address = account.get_address() if address is None else address
438437

439438
data = await get(

src/aleph_client/commands/domain.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
from pathlib import Path
55
from time import sleep
6-
from typing import Annotated, Optional, cast
6+
from typing import Annotated, Optional, Union, cast
77

88
import typer
99
from aleph.sdk.account import _load_account
@@ -19,6 +19,7 @@
1919
from aleph.sdk.exceptions import DomainConfigurationError
2020
from aleph.sdk.query.filters import MessageFilter
2121
from aleph.sdk.types import AccountFromPrivateKey
22+
from aleph.sdk.wallets.ledger import LedgerETHAccount
2223
from aleph_message.models import AggregateMessage
2324
from aleph_message.models.base import MessageType
2425
from rich.console import Console
@@ -65,7 +66,7 @@ async def check_domain_records(fqdn, target, owner):
6566

6667

6768
async def attach_resource(
68-
account: AccountFromPrivateKey,
69+
account,
6970
fqdn: Hostname,
7071
item_hash: Optional[str] = None,
7172
catch_all_path: Optional[str] = None,
@@ -137,7 +138,9 @@ async def attach_resource(
137138
)
138139

139140

140-
async def detach_resource(account: AccountFromPrivateKey, fqdn: Hostname, interactive: Optional[bool] = None):
141+
async def detach_resource(
142+
account: Union[AccountFromPrivateKey, LedgerETHAccount], fqdn: Hostname, interactive: Optional[bool] = None
143+
):
141144
domain_info = await get_aggregate_domain_info(account, fqdn)
142145
interactive = is_environment_interactive() if interactive is None else interactive
143146

@@ -187,7 +190,7 @@ async def add(
187190
] = settings.PRIVATE_KEY_FILE,
188191
):
189192
"""Add and link a Custom Domain."""
190-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
193+
account = _load_account(private_key, private_key_file)
191194
interactive = False if (not ask) else is_environment_interactive()
192195

193196
console = Console()
@@ -272,7 +275,7 @@ async def attach(
272275
] = settings.PRIVATE_KEY_FILE,
273276
):
274277
"""Attach resource to a Custom Domain."""
275-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
278+
account = _load_account(private_key, private_key_file)
276279

277280
await attach_resource(
278281
account,
@@ -294,7 +297,7 @@ async def detach(
294297
] = settings.PRIVATE_KEY_FILE,
295298
):
296299
"""Unlink Custom Domain."""
297-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
300+
account = _load_account(private_key, private_key_file)
298301

299302
await detach_resource(account, Hostname(fqdn), interactive=False if (not ask) else None)
300303
raise typer.Exit()
@@ -309,7 +312,7 @@ async def info(
309312
] = settings.PRIVATE_KEY_FILE,
310313
):
311314
"""Show Custom Domain Details."""
312-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
315+
account = _load_account(private_key, private_key_file)
313316

314317
console = Console()
315318
domain_validator = DomainValidator()

src/aleph_client/commands/files.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from aleph.sdk import AlephHttpClient, AuthenticatedAlephHttpClient
1313
from aleph.sdk.account import _load_account
1414
from aleph.sdk.conf import settings
15-
from aleph.sdk.types import AccountFromPrivateKey, StorageEnum, StoredContent
15+
from aleph.sdk.types import StorageEnum, StoredContent
1616
from aleph.sdk.utils import safe_getattr
1717
from aleph_message.models import ItemHash, StoreMessage
1818
from aleph_message.status import MessageStatus
@@ -44,7 +44,7 @@ async def pin(
4444

4545
setup_logging(debug)
4646

47-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
47+
account = _load_account(private_key, private_key_file)
4848

4949
async with AuthenticatedAlephHttpClient(account=account, api_server=settings.API_HOST) as client:
5050
result: StoreMessage
@@ -75,7 +75,7 @@ async def upload(
7575

7676
setup_logging(debug)
7777

78-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
78+
account = _load_account(private_key, private_key_file)
7979

8080
async with AuthenticatedAlephHttpClient(account=account, api_server=settings.API_HOST) as client:
8181
if not path.is_file():
@@ -181,7 +181,7 @@ async def forget(
181181

182182
setup_logging(debug)
183183

184-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
184+
account = _load_account(private_key, private_key_file)
185185

186186
hashes = [ItemHash(item_hash) for item_hash in item_hash.split(",")]
187187

@@ -270,7 +270,7 @@ async def list_files(
270270
json: Annotated[bool, typer.Option(help="Print as json instead of rich table")] = False,
271271
):
272272
"""List all files for a given address"""
273-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
273+
account = _load_account(private_key, private_key_file)
274274

275275
if account and not address:
276276
address = account.get_address()

src/aleph_client/commands/message.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121
from aleph.sdk.query.filters import MessageFilter
2222
from aleph.sdk.query.responses import MessagesResponse
23-
from aleph.sdk.types import AccountFromPrivateKey, StorageEnum
23+
from aleph.sdk.types import StorageEnum
2424
from aleph.sdk.utils import extended_json_encoder
2525
from aleph_message.models import AlephMessage, ProgramMessage
2626
from aleph_message.models.base import MessageType
@@ -138,7 +138,7 @@ async def post(
138138

139139
setup_logging(debug)
140140

141-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
141+
account = _load_account(private_key, private_key_file)
142142
storage_engine: StorageEnum
143143
content: dict
144144

@@ -188,7 +188,7 @@ async def amend(
188188

189189
setup_logging(debug)
190190

191-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
191+
account = _load_account(private_key, private_key_file)
192192

193193
async with AlephHttpClient(api_server=settings.API_HOST) as client:
194194
existing_message: Optional[AlephMessage] = None
@@ -253,7 +253,7 @@ async def forget(
253253

254254
hash_list: list[ItemHash] = [ItemHash(h) for h in hashes.split(",")]
255255

256-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
256+
account = _load_account(private_key, private_key_file)
257257
async with AuthenticatedAlephHttpClient(account=account, api_server=settings.API_HOST) as client:
258258
await client.forget(hashes=hash_list, reason=reason, channel=channel)
259259

@@ -296,7 +296,7 @@ def sign(
296296

297297
setup_logging(debug)
298298

299-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
299+
account = _load_account(private_key, private_key_file)
300300

301301
if message is None:
302302
message = input_multiline()

src/aleph_client/commands/program.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525
from aleph.sdk.query.filters import MessageFilter
2626
from aleph.sdk.query.responses import PriceResponse
27-
from aleph.sdk.types import AccountFromPrivateKey, StorageEnum, TokenType
27+
from aleph.sdk.types import StorageEnum, TokenType
2828
from aleph.sdk.utils import displayable_amount, make_program_content, safe_getattr
2929
from aleph_message.models import (
3030
Chain,
@@ -127,7 +127,7 @@ async def upload(
127127
typer.echo("No such file or directory")
128128
raise typer.Exit(code=4) from error
129129

130-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file, chain=payment_chain)
130+
account = _load_account(private_key, private_key_file, chain=payment_chain)
131131
address = address or settings.ADDRESS_TO_USE or account.get_address()
132132

133133
# Loads default configuration if no chain is set
@@ -339,7 +339,7 @@ async def update(
339339
typer.echo("No such file or directory")
340340
raise typer.Exit(code=4) from error
341341

342-
account: AccountFromPrivateKey = _load_account(private_key, private_key_file, chain=chain)
342+
account = _load_account(private_key, private_key_file, chain=chain)
343343

344344
async with AuthenticatedAlephHttpClient(account=account, api_server=settings.API_HOST) as client:
345345
try:

0 commit comments

Comments
 (0)