diff --git a/pythclient/config.py b/pythclient/config.py index 877d254..c9f1dbb 100644 --- a/pythclient/config.py +++ b/pythclient/config.py @@ -2,13 +2,13 @@ Library-wide settings. """ -backoff_max_value = 16 -backoff_max_tries = 8 +BACKOFF_MAX_VALUE = 16 +BACKOFF_MAX_TRIES = 8 # The following getter functions are passed to the backoff decorators -def get_backoff_max_value(): - return backoff_max_value +def get_backoff_max_value() -> int: + return BACKOFF_MAX_VALUE -def get_backoff_max_tries(): - return backoff_max_tries +def get_backoff_max_tries() -> int: + return BACKOFF_MAX_TRIES diff --git a/pythclient/price_feeds.py b/pythclient/price_feeds.py index 2dc337f..d5275f6 100644 --- a/pythclient/price_feeds.py +++ b/pythclient/price_feeds.py @@ -19,7 +19,7 @@ class Price: - def __init__(self, conf, expo, price, publish_time): + def __init__(self, conf, expo, price, publish_time) -> None: self.conf = conf self.expo = expo self.price = price @@ -38,7 +38,7 @@ def to_dict(self): class PriceUpdate: - def __init__(self, ema_price, price_id, price): + def __init__(self, ema_price, price_id, price) -> None: self.ema_price = ema_price self.id = price_id self.price = price @@ -66,7 +66,7 @@ def __init__( last_attested_publish_time, price_feed, emitter_chain_id, - ): + ) -> None: self.seq_num = seq_num self.vaa = vaa self.publish_time = publish_time @@ -117,7 +117,7 @@ def to_dict(self, verbose=False, vaa_format=DEFAULT_VAA_ENCODING): class MerkleUpdate: def __init__( self, message_size: int, message: bytes, proof_size: int, proof: List[bytes] - ): + ) -> None: self.message_size = message_size self.message = message self.proof_size = proof_size @@ -142,7 +142,7 @@ def __init__( vaa: bytes, num_updates: int, updates: List[MerkleUpdate], - ): + ) -> None: self.magic = magic self.major_version = major_version self.minor_version = minor_version @@ -195,7 +195,7 @@ def encode_vaa_for_chain(vaa: str, vaa_format: str, buffer=False) -> Union[bytes # Referenced from https://github.com/wormhole-foundation/wormhole/blob/main/sdk/js/src/vaa/wormhole.ts#L26-L56 -def parse_vaa(vaa, encoding): +def parse_vaa(vaa: str, encoding: str) -> dict: vaa = cast(bytes, encode_vaa_for_chain(vaa, encoding, buffer=True)) num_signers = vaa[5] diff --git a/pythclient/pythaccounts.py b/pythclient/pythaccounts.py index fa36598..a035c43 100644 --- a/pythclient/pythaccounts.py +++ b/pythclient/pythaccounts.py @@ -78,7 +78,7 @@ def _read_attribute_string(buffer: bytes, offset: int) -> Tuple[Optional[str], i return data.decode('utf8', 'replace'), data_end -def _parse_header(buffer: bytes, offset: int = 0, *, key: SolanaPublicKeyOrStr): +def _parse_header(buffer: bytes, offset: int = 0, *, key: SolanaPublicKeyOrStr) -> Tuple[PythAccountType, int, int]: if len(buffer) - offset < _ACCOUNT_HEADER_BYTES: raise ValueError("Pyth account data too short")