Skip to content

Commit ad58cdc

Browse files
authored
Refactor ETH price fetching to use direct import
1 parent ef2a48c commit ad58cdc

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

web_programming/crypto_price.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# ]
1010
# ///
1111

12-
import httpx2
12+
from httpx2 import get
1313

1414
COINGECKO_URL = (
1515
"https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd"
@@ -18,11 +18,7 @@
1818

1919
def get_eth_price_usd() -> float:
2020
"""Fetch the current ETH price in USD."""
21-
return (
22-
httpx2.get(COINGECKO_URL, timeout=10)
23-
.raise_for_status()
24-
.json()["ethereum"]["usd"]
25-
)
21+
return get(COINGECKO_URL, timeout=10).raise_for_status().json()["ethereum"]["usd"]
2622

2723

2824
def eth_to_usd(eth_amount: float) -> float:

0 commit comments

Comments
 (0)