From 15d38a03e4016cb265299c2de9863bcb73079d7f Mon Sep 17 00:00:00 2001 From: gabrielfior Date: Tue, 9 Jul 2024 15:33:29 +0200 Subject: [PATCH] Fixed mypy --- general_agent/functions.py | 18 +++++++++--------- general_agent/remote_runner.py | 2 +- general_agent/web3_functions.py | 12 ++++++------ mypy.ini | 2 +- pyproject.toml | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/general_agent/functions.py b/general_agent/functions.py index 21f84f6..fc713e6 100644 --- a/general_agent/functions.py +++ b/general_agent/functions.py @@ -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 \ No newline at end of file diff --git a/general_agent/remote_runner.py b/general_agent/remote_runner.py index dcaa84b..d0c5d25 100644 --- a/general_agent/remote_runner.py +++ b/general_agent/remote_runner.py @@ -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() \ No newline at end of file diff --git a/general_agent/web3_functions.py b/general_agent/web3_functions.py index 49b0d38..2f3c26b 100644 --- a/general_agent/web3_functions.py +++ b/general_agent/web3_functions.py @@ -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 @@ -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 \ No newline at end of file + return str(acc.address) \ No newline at end of file diff --git a/mypy.ini b/mypy.ini index 42bb821..f08ef5b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -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 diff --git a/pyproject.toml b/pyproject.toml index a67dc55..3df9475 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "trader" +name = "general_agent" version = "0.1.0" description = "" authors = ["Gnosis Labs "]