Skip to content

Commit

Permalink
fix: pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro-Morales committed Sep 29, 2023
1 parent f5269d3 commit 7e62da3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 2 additions & 0 deletions python/examples/06-send-tokens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from uagents.network import wait_for_tx_to_complete
from uagents.setup import fund_agent_if_low

# pylint: disable=protected-access


class PaymentRequest(Model):
wallet_address: str
Expand Down
8 changes: 5 additions & 3 deletions python/examples/13-agent-name-service/agent1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cosmpy.aerial.wallet import LocalWallet

from uagents.network import get_ledger, get_faucet, get_name_service_contract
from uagents.network import get_faucet, get_name_service_contract
from uagents.setup import fund_agent_if_low
from uagents import Agent, Context, Model

Expand All @@ -9,6 +9,8 @@

# NOTE: Run agent1.py before running agent2.py

# pylint: disable=protected-access


class Message(Model):
message: str
Expand All @@ -28,9 +30,9 @@ class Message(Model):
DOMAIN = "agent"

faucet = get_faucet()
agent_balance = bob._ledger.query_bank_balance(my_wallet)
AGENT_BALANCE = bob._ledger.query_bank_balance(my_wallet)

if agent_balance < REGISTRATION_FEE:
if AGENT_BALANCE < REGISTRATION_FEE:
print("Adding funds to wallet...")
faucet.get_wealth(my_wallet)
print("Adding funds to wallet...complete")
Expand Down
3 changes: 2 additions & 1 deletion python/src/uagents/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import sys
from enum import Enum

# from enum import Enum
from typing import Any, Dict, List, Optional, Union

from uvicorn.logging import DefaultFormatter
Expand Down
10 changes: 5 additions & 5 deletions python/src/uagents/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from uagents.config import DEFAULT_MAX_ENDPOINTS
from uagents.network import get_almanac_contract, get_name_service_contract

_testnet_prefixe = "test-agent://"
_mainnet_prefix = "agent://"
TESTNET_PREFIX = "test-agent://"
MAINNET_PREFIX = "agent://"


def query_record(agent_address: str, service: str, test: bool) -> dict:
Expand Down Expand Up @@ -62,7 +62,7 @@ def is_agent_address(address) -> tuple:
if not isinstance(address, str):
return False

prefixes = [_testnet_prefixe, _mainnet_prefix, ""]
prefixes = [TESTNET_PREFIX, MAINNET_PREFIX, ""]
expected_length = 65

for prefix in prefixes:
Expand Down Expand Up @@ -115,10 +115,10 @@ async def resolve(self, destination: str) -> Tuple[Optional[str], List[str]]:
is_address, prefix = is_agent_address(destination)
if is_address:
return await self._almanc_resolver.resolve(
destination[len(prefix) :], not prefix == _mainnet_prefix
destination[len(prefix) :], not prefix == MAINNET_PREFIX
)
return await self._name_service_resolver.resolve(
destination, not prefix == _mainnet_prefix
destination, not prefix == MAINNET_PREFIX
)


Expand Down
8 changes: 5 additions & 3 deletions python/src/uagents/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
LOGGER = get_logger("setup")


# pylint: disable=protected-access
def fund_agent_if_low(agent: Agent):
"""
Checks the agent's wallet balance and adds funds if it's below the registration fee.
Expand All @@ -27,7 +28,8 @@ def fund_agent_if_low(agent: Agent):

if not agent._test:
LOGGER.warning(
f"Faucet only available for testnet, please add FET tokens to your wallet {agent.wallet.address()}"
"Faucet only available for testnet, please add FET tokens to your wallet "
f"{agent.wallet.address()}"
)
LOGGER.info(f"Current FET balance: {agent_balance}")
return
Expand All @@ -37,8 +39,8 @@ def fund_agent_if_low(agent: Agent):
LOGGER.info("Adding funds to agent...")
faucet.get_wealth(agent.wallet.address())
LOGGER.info("Adding funds to agent...complete")
except Exception as e:
LOGGER.error(f"Failed to add funds to agent: {str(e)}")
except Exception as ex:
LOGGER.error(f"Failed to add funds to agent: {str(ex)}")


def register_agent_with_mailbox(agent: Agent, email: str):
Expand Down

0 comments on commit 7e62da3

Please sign in to comment.