Skip to content

Commit

Permalink
Add py.typed (#59)
Browse files Browse the repository at this point in the history
* Add py.typed

* Fix fetch_json typing
  • Loading branch information
evgeny-stakewise authored Sep 3, 2023
1 parent 28caca5 commit 7096a25
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sw-utils"
version = "0.3.22"
version = "0.3.23"
description = "StakeWise Python utils"
authors = ["StakeWise Labs <[email protected]>"]
license = "GPL-3.0-or-later"
Expand Down
6 changes: 3 additions & 3 deletions sw_utils/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _ipfs_fetch_bytes(self, endpoint: str, ipfs_hash: str) -> bytes:
) as client:
return client.cat(ipfs_hash, timeout=self.timeout)

async def fetch_json(self, ipfs_hash: str) -> dict | list:
async def fetch_json(self, ipfs_hash: str) -> Any:
"""Tries to fetch IPFS hash from different sources."""
if not ipfs_hash:
raise ValueError('Empty IPFS hash provided')
Expand All @@ -295,13 +295,13 @@ async def fetch_json(self, ipfs_hash: str) -> dict | list:

raise IpfsException(f'Failed to fetch IPFS data at {ipfs_hash}')

async def _http_gateway_fetch_json(self, endpoint: str, ipfs_hash: str) -> dict | list:
async def _http_gateway_fetch_json(self, endpoint: str, ipfs_hash: str) -> Any:
async with ClientSession(timeout=ClientTimeout(self.timeout)) as session:
async with session.get(f"{endpoint.rstrip('/')}/ipfs/{ipfs_hash}") as response:
response.raise_for_status()
return await response.json()

def _ipfs_fetch_json(self, endpoint: str, ipfs_hash: str) -> dict | list:
def _ipfs_fetch_json(self, endpoint: str, ipfs_hash: str) -> Any:
with ipfshttpclient.connect(
endpoint,
) as client:
Expand Down
Empty file added sw_utils/py.typed
Empty file.

0 comments on commit 7096a25

Please sign in to comment.