Skip to content

Commit

Permalink
Fixed mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfior committed Jul 9, 2024
1 parent a1206d1 commit 15d38a0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions general_agent/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@

class Sum(Function):
@property
def description(self):
def description(self) -> str:
return "Use this function to compute the sum of two numbers"

@property
def example_args(self):
def example_args(self) -> list[float]:
return [2, 2]

def __call__(self, a: float, b: float):
def __call__(self, a: float, b: float) -> float:
return a + b


class Product(Function):
@property
def description(self):
def description(self) -> str:
return "Use this function to compute the product of two numbers"

@property
def example_args(self):
def example_args(self) -> list[int]:
return [2, 2]

def __call__(self, a: float, b: float):
def __call__(self, a: float, b: float) -> float:
return a * b


class GreaterThan(Function):
@property
def description(self):
def description(self) -> str:
return (
"Use this function to assess if one number is greater than the other number"
)

@property
def example_args(self):
def example_args(self) -> list[float]:
return [2, 2]

def __call__(self, a: float, b: float):
def __call__(self, a: float, b: float) -> bool:
return a > b
2 changes: 1 addition & 1 deletion general_agent/remote_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
@app.function(
schedule=Period(minutes=5), secrets=[Secret.from_dotenv(path_to_env.as_posix())]
)
def execute_remote():
def execute_remote() -> None:
main()
12 changes: 6 additions & 6 deletions general_agent/web3_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from eth_account import Account
from eth_typing import ChecksumAddress
from eth_typing import ChecksumAddress, Wei
from microchain import Function
from web3 import Web3

Expand All @@ -16,29 +16,29 @@ def __init__(self) -> None:
super().__init__()

@property
def description(self):
def description(self) -> str:
return "Use this function to fetch the balance of a given account in xDAI"

@property
def example_args(self) -> list[ChecksumAddress]:
return [Web3.to_checksum_address("0x464A10A122Cb5B47e9B27B9c5286BC27487a6ACd")]

def __call__(self, address: ChecksumAddress):
def __call__(self, address: ChecksumAddress) -> Wei:
return self.w3.eth.get_balance(account=address)


class GetOwnWallet(Function):
@property
def description(self):
def description(self) -> str:
return "Use this function to fetch your wallet address"

@property
def example_args(self) -> list[str]:
return []

def __call__(self):
def __call__(self) -> str:
private_key = os.getenv("BET_FROM_PRIVATE_KEY")
if not private_key:
raise EnvironmentError("BET_FROM_PRIVATE_KEY missing in the environment.")
acc = Account.from_key(private_key)
return acc.address
return str(acc.address)
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
python_version = 3.10
files = trader/
files = general_agent/
plugins = pydantic.mypy
warn_redundant_casts = True
warn_unused_ignores = True
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "trader"
name = "general_agent"
version = "0.1.0"
description = ""
authors = ["Gnosis Labs <[email protected]>"]
Expand Down

0 comments on commit 15d38a0

Please sign in to comment.