Skip to content

Commit 675943a

Browse files
committed
Make the diagnostic example code compatible with pydantic 1 and 2
so it doesn't fail in the ci
1 parent 2be5876 commit 675943a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/example_fastapi/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from fastapi.middleware.cors import CORSMiddleware
2323
from fastapi.responses import PlainTextResponse
2424
from pip._internal.operations.freeze import freeze
25-
from pydantic import BaseModel, HttpUrl
25+
from pydantic import BaseModel
2626
from starlette.responses import JSONResponse
2727

2828
from aleph.sdk.chains.remote import RemoteAccount
@@ -198,7 +198,7 @@ async def connect_ipv6():
198198
return {"result": False, "reason": str(error.args[0])}
199199

200200

201-
async def check_url(internet_host: HttpUrl, timeout_seconds: int = 5, socket_family=socket.AF_INET):
201+
async def check_url(internet_host: str, timeout_seconds: int = 5, socket_family=socket.AF_INET):
202202
"""Check the connectivity of a single URL."""
203203
timeout = aiohttp.ClientTimeout(total=timeout_seconds)
204204
tcp_connector = aiohttp.TCPConnector(family=socket_family)
@@ -215,10 +215,10 @@ async def check_url(internet_host: HttpUrl, timeout_seconds: int = 5, socket_fam
215215
@app.get("/internet")
216216
async def read_internet():
217217
"""Check Internet connectivity of the system, requiring IP connectivity, domain resolution and HTTPS/TLS."""
218-
internet_hosts: list[HttpUrl] = [
219-
HttpUrl(url="https://aleph.im/", scheme="https"),
220-
HttpUrl(url="https://ethereum.org/en/", scheme="https"),
221-
HttpUrl(url="https://ipfs.io/", scheme="https"),
218+
internet_hosts: list[str] = [
219+
"https://aleph.im/",
220+
"https://ethereum.org/en/",
221+
"https://ipfs.io/",
222222
]
223223
timeout_seconds = 5
224224

0 commit comments

Comments
 (0)