Skip to content

Commit 6c1d8de

Browse files
codebydivineclaude
andcommitted
fix: resolve specific Ruff linting issues
- Fixed import sorting in sol_price.py example (I001) - Sorted __all__ lists in __init__.py and types.py (RUF022) - Suppressed password warnings for public Solana program IDs (S105) - Converted nested with statements to single with statements (SIM117) - Added allowlist comments for test secrets 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 0c3e6fb commit 6c1d8de

File tree

18 files changed

+383
-367
lines changed

18 files changed

+383
-367
lines changed

examples/endpoints/evm/balances.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ async def main():
4242

4343
print("\n✅ Portfolio loaded!")
4444

45-
except Exception as e:
46-
print(f"❌ Failed to load portfolio: {e}")
47-
print("💡 Make sure your API key is set: export THEGRAPH_API_KEY='your_key'") # pragma: allowlist secret
45+
except (ValueError, RuntimeError, OSError) as e:
46+
print(f"\u274c Failed to load portfolio: {e}")
47+
print(
48+
"\ud83d\udca1 Make sure your API key is set: export THEGRAPH_API_KEY='your_key'" # pragma: allowlist secret
49+
)
4850

4951

5052
if __name__ == "__main__":

examples/endpoints/evm/health.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ async def main():
2828
else:
2929
print(f"⚠️ API status: {health}")
3030

31-
except Exception as e:
32-
print(f" Connection failed: {e}")
33-
print("💡 Check your THEGRAPH_API_KEY environment variable")
31+
except (ValueError, RuntimeError, OSError) as e:
32+
print(f"\u274c Connection failed: {e}")
33+
print("\ud83d\udca1 Check your THEGRAPH_API_KEY environment variable")
3434

3535

3636
if __name__ == "__main__":

examples/endpoints/evm/nfts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ async def main():
5353

5454
print("\n✅ NFT data loaded!")
5555

56-
except Exception as e:
57-
print(f" Failed to load NFT data: {e}")
58-
print("💡 NFT queries can be slow - this is normal!")
56+
except (ValueError, RuntimeError, OSError) as e:
57+
print(f"\u274c Failed to load NFT data: {e}")
58+
print("\ud83d\udca1 NFT queries can be slow - this is normal!")
5959

6060

6161
if __name__ == "__main__":

examples/endpoints/evm/prices.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ async def main():
2727
print("=" * 16)
2828

2929
api = TokenAPI()
30-
link_token = "0x514910771AF9Ca656af840dff83E8264EcF986CA" # nosec B105
30+
link_address = "0x514910771AF9Ca656af840dff83E8264EcF986CA" # nosec B105 # not a password, this is a public token address
3131
uniswap_pool = "0x3E456E2A71adafb6fe0AF8098334ee41ef53A7C6"
3232

3333
try:
3434
# Token price history
3535
print("🔗 LINK Token (7 days):")
3636
prices = await api.evm.price_history(
37-
token=link_token,
37+
token=link_address,
3838
interval=Interval.ONE_DAY,
3939
days=7,
4040
)
@@ -64,9 +64,9 @@ async def main():
6464

6565
print("\n✅ Price data loaded!")
6666

67-
except Exception as e:
68-
print(f" Failed to load price data: {e}")
69-
print("💡 Price queries can take longer for historical data")
67+
except (ValueError, RuntimeError, OSError) as e:
68+
print(f"\u274c Failed to load price data: {e}")
69+
print("\ud83d\udca1 Price queries can take longer for historical data")
7070

7171

7272
if __name__ == "__main__":

examples/endpoints/evm/swaps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ async def main():
4242

4343
print("\n✅ Swap data retrieved successfully!")
4444

45-
except Exception as e:
46-
print(f" Error: {e}")
45+
except (ValueError, RuntimeError, OSError) as e:
46+
print(f"\u274c Error: {e}")
4747

4848

4949
if __name__ == "__main__":

examples/endpoints/evm/tokens.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ async def main():
4141
formatted = f"{value:,.0f}" if value > 1000 else f"{value:.2f}"
4242
print(f" {i}. {address} | {formatted}")
4343

44-
except Exception:
44+
except (ValueError, RuntimeError, OSError):
4545
print(" (Request timeout - common for popular tokens)")
4646

4747
print("\n✅ Token data retrieved successfully!")
4848

49-
except Exception as e:
50-
print(f" Error: {e}")
49+
except (ValueError, RuntimeError, OSError) as e:
50+
print(f"\u274c Error: {e}")
5151

5252

5353
if __name__ == "__main__":

examples/endpoints/evm/transfers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ async def main():
1919

2020
api = TokenAPI()
2121
wallet = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" # Vitalik's wallet
22-
imagine_token = "0x6A1B2AE3a55B5661b40d86c2bF805f7DAdB16978" # nosec B105
22+
imagine_address = "0x6A1B2AE3a55B5661b40d86c2bF805f7DAdB16978" # nosec B105 # not a password, this is a public token address
2323

2424
try:
2525
# Token-specific transfers
2626
print("📦 Recent Token Transfers:")
27-
transfers = await api.evm.transfers(contract=imagine_token, limit=3)
27+
transfers = await api.evm.transfers(contract=imagine_address, limit=3)
2828

2929
for i, transfer in enumerate(transfers, 1):
3030
amount = transfer.value
@@ -47,9 +47,9 @@ async def main():
4747

4848
print("\n✅ Transfer data loaded!")
4949

50-
except Exception as e:
51-
print(f" Failed to load transfers: {e}")
52-
print("💡 Transfer queries cover recent blockchain activity")
50+
except (ValueError, RuntimeError, OSError) as e:
51+
print(f"\u274c Failed to load transfers: {e}")
52+
print("\ud83d\udca1 Transfer queries cover recent blockchain activity")
5353

5454

5555
if __name__ == "__main__":

examples/endpoints/svm/balances.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ async def main():
2323
decimals = balance.decimals
2424

2525
# Simple decimal formatting
26-
if decimals > 0:
27-
formatted = f"{float(amount) / (10**decimals):.2f}"
28-
else:
29-
formatted = amount
26+
formatted = f"{float(amount) / (10**decimals):.2f}" if decimals > 0 else amount
3027

3128
print(f" {i}. {mint}: {formatted}")
3229

@@ -58,8 +55,8 @@ async def main():
5855

5956
print("\n✅ Solana balances retrieved successfully!")
6057

61-
except Exception as e:
62-
print(f" Error: {e}")
58+
except (ValueError, RuntimeError, OSError) as e:
59+
print(f"\u274c Error: {e}")
6360

6461

6562
if __name__ == "__main__":

examples/endpoints/svm/sol_price.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import sys
1414
import time
1515
from datetime import datetime
16+
from pathlib import Path
1617

17-
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
18+
# Use pathlib to resolve the parent directory four levels up
19+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent.parent))
1820

1921
from dotenv import load_dotenv
2022

@@ -28,7 +30,7 @@ async def example_simple_usage():
2830
"""Example: Super simple SOL price - just one line!"""
2931
print("\n=== ✨ Optimized Simple Usage ===")
3032

31-
api_key = os.getenv("THEGRAPH_API_KEY")
33+
api_key = os.environ.get("THEGRAPH_API_KEY")
3234
if not api_key:
3335
print("Error: THEGRAPH_API_KEY not found in environment")
3436
return
@@ -50,7 +52,7 @@ async def example_with_confidence():
5052
"""Example: Get SOL price with confidence and stats."""
5153
print("\n=== 📊 Price with Intelligence ===")
5254

53-
api_key = os.getenv("THEGRAPH_API_KEY")
55+
api_key = os.environ.get("THEGRAPH_API_KEY")
5456
if not api_key:
5557
print("Error: THEGRAPH_API_KEY not found in environment")
5658
return
@@ -82,7 +84,7 @@ async def example_cached_performance():
8284
"""Example: Show smart caching in action."""
8385
print("\n=== ⚡ Smart Caching Demo ===")
8486

85-
api_key = os.getenv("THEGRAPH_API_KEY")
87+
api_key = os.environ.get("THEGRAPH_API_KEY")
8688
if not api_key:
8789
print("Error: THEGRAPH_API_KEY not found in environment")
8890
return
@@ -115,7 +117,7 @@ async def example_integration():
115117
"""Example: Show how it integrates seamlessly with other SVM functions."""
116118
print("\n=== 🔗 Seamless Integration ===")
117119

118-
api_key = os.getenv("THEGRAPH_API_KEY")
120+
api_key = os.environ.get("THEGRAPH_API_KEY")
119121
if not api_key:
120122
print("Error: THEGRAPH_API_KEY not found in environment")
121123
return

examples/endpoints/svm/swaps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ async def main():
6464

6565
print("\n✅ Solana trading data loaded!")
6666

67-
except Exception as e:
68-
print(f" Failed to load Solana data: {e}")
69-
print("💡 Solana queries can take a moment...")
67+
except (ValueError, RuntimeError, OSError) as e:
68+
print(f"\u274c Failed to load Solana data: {e}")
69+
print("\ud83d\udca1 Solana queries can take a moment...")
7070

7171

7272
if __name__ == "__main__":

0 commit comments

Comments
 (0)