From c688dc3ba054269d7c711ce181428809fe90e2da Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Mon, 8 Apr 2024 22:54:27 +0000 Subject: [PATCH] chore: fmt f-strings lazily --- scripts/exporters/wallets.py | 2 +- yearn/helpers/snapshots.py | 2 +- yearn/outputs/victoria/victoria.py | 2 +- yearn/partners/snapshot.py | 2 +- yearn/prices/magic.py | 2 +- yearn/prices/uniswap/v2.py | 2 +- yearn/treasury/accountant/__init__.py | 2 +- yearn/treasury/accountant/classes.py | 6 +++++- 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/exporters/wallets.py b/scripts/exporters/wallets.py index 47ed16322..b3f7a09f0 100644 --- a/scripts/exporters/wallets.py +++ b/scripts/exporters/wallets.py @@ -37,7 +37,7 @@ def get_last_recorded_block(): def postgres_ready(snapshot: datetime) -> bool: if (postgres_cached_thru_block := get_last_recorded_block()): return chain[postgres_cached_thru_block].timestamp >= snapshot.timestamp() - logger.debug(f"postgress not yet popuated for {snapshot}") + logger.debug("postgress not yet popuated for %s", snapshot) return False class WalletExporter(Exporter): diff --git a/yearn/helpers/snapshots.py b/yearn/helpers/snapshots.py index a9cef1f43..5ef71011c 100644 --- a/yearn/helpers/snapshots.py +++ b/yearn/helpers/snapshots.py @@ -19,7 +19,7 @@ async def _generate_snapshot_range_forward(start: datetime, interval: timedelta) snapshot = start + i * interval while snapshot > datetime.now(tz=timezone.utc) + REORG_BUFFER: diff = snapshot - datetime.now(tz=timezone.utc) + REORG_BUFFER - logger.debug(f"SLEEPING {diff}") + logger.debug("SLEEPING %s", diff) await asyncio.sleep(diff.total_seconds()) yield snapshot diff --git a/yearn/outputs/victoria/victoria.py b/yearn/outputs/victoria/victoria.py index e4a5b9ce2..87d9ab2b1 100644 --- a/yearn/outputs/victoria/victoria.py +++ b/yearn/outputs/victoria/victoria.py @@ -72,7 +72,7 @@ async def _post(metrics_to_export: List[Dict]) -> None: if not isinstance(e, aiohttp.ClientError): raise e attempts += 1 - logger.debug(f'You had a ClientError: {e}') + logger.debug('You had a ClientError: %s', e) if attempts >= 10: raise e diff --git a/yearn/partners/snapshot.py b/yearn/partners/snapshot.py index 66ea4f2c2..e1e584ca0 100644 --- a/yearn/partners/snapshot.py +++ b/yearn/partners/snapshot.py @@ -92,7 +92,7 @@ async def get_data(self, partner: "Partner", use_postgres_cache: bool, verbose: except KeyError: start_block = partner.start_block logger.debug('no harvests cached for %s %s', partner.name, self.name) - logger.debug(f'start block: {start_block}') + logger.debug('start block: %s', start_block) else: start_block = partner.start_block diff --git a/yearn/prices/magic.py b/yearn/prices/magic.py index f22b05c58..ec4bbb378 100644 --- a/yearn/prices/magic.py +++ b/yearn/prices/magic.py @@ -163,7 +163,7 @@ def find_price( if price is None and return_price_during_vault_downtime: for incident in INCIDENTS[token]: if incident['start'] <= block <= incident['end']: - logger.debug(f"incidents -> {price}") + logger.debug("incidents -> %s", price) return incident['result'] if price is None: diff --git a/yearn/prices/uniswap/v2.py b/yearn/prices/uniswap/v2.py index c9f014f38..d0dea5e0d 100644 --- a/yearn/prices/uniswap/v2.py +++ b/yearn/prices/uniswap/v2.py @@ -205,7 +205,7 @@ def pools(self) -> Dict[Address,Dict[Address,Address]]: if len(pairs) < all_pairs_len: logger.debug("Oh no! looks like your node can't look back that far. Checking for the missing pools...") poolids_your_node_couldnt_get = [i for i in range(all_pairs_len) if i not in pairs] - logger.debug(f'missing poolids: {poolids_your_node_couldnt_get}') + logger.debug('missing poolids: %s', poolids_your_node_couldnt_get) pools_your_node_couldnt_get = fetch_multicall(*[[self.factory,'allPairs',i] for i in poolids_your_node_couldnt_get]) token0s = fetch_multicall(*[[contract(pool), 'token0'] for pool in pools_your_node_couldnt_get if pool not in self.excluded_pools()]) token1s = fetch_multicall(*[[contract(pool), 'token1'] for pool in pools_your_node_couldnt_get if pool not in self.excluded_pools()]) diff --git a/yearn/treasury/accountant/__init__.py b/yearn/treasury/accountant/__init__.py index 8c9ec1527..808f65f54 100644 --- a/yearn/treasury/accountant/__init__.py +++ b/yearn/treasury/accountant/__init__.py @@ -73,7 +73,7 @@ def __ensure_signatures_are_known(addresses: List[Address]) -> None: no_sigs.append(address) except ContractNotFound: # This is MOST LIKELY unimportant and not Yearn related. - logger.debug(f"{address.address} self destructed") + logger.debug("%s self destructed", address.address) except ValueError as e: if str(e).startswith("Source for") and str(e).endswith("has not been verified"): continue diff --git a/yearn/treasury/accountant/classes.py b/yearn/treasury/accountant/classes.py index 42c5f0ac5..81d782e74 100644 --- a/yearn/treasury/accountant/classes.py +++ b/yearn/treasury/accountant/classes.py @@ -3,6 +3,8 @@ from typing import Any, Callable, Iterable, List, Optional, Tuple, Union import sentry_sdk +from y import ContractNotVerified + from yearn.entities import TreasuryTx, TxGroup from yearn.outputs.postgres.utils import cache_txgroup @@ -57,8 +59,10 @@ def sort(self, tx: TreasuryTx) -> Optional[TxGroup]: try: if hasattr(self, 'check') and self.check(tx): return self.txgroup + except ContractNotVerified: + logger.info("ContractNotVerified when sorting %s with %s", tx, self.label) except Exception as e: - logger.warning(f"{e.__repr__()} when sorting {tx} with {self.label}.") + logger.warning("%s when sorting %s with %s.", e.__repr__(), tx, self.label) sentry_sdk.capture_exception(e) return None return super().sort(tx)