Skip to content

Commit 4ab26e9

Browse files
authored
Fix typehint (#226)
Fixes the `node.fetch` typehint since only strings (and not lists of strings) are accepted. It also removes a related test.
1 parent 1112f51 commit 4ab26e9

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

datacommons_client/endpoints/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, api: API):
2222
def fetch(
2323
self,
2424
node_dcids: str | list[str],
25-
expression: str | list[str],
25+
expression: str,
2626
*,
2727
all_pages: bool = True,
2828
next_token: Optional[str] = None,
@@ -31,7 +31,7 @@ def fetch(
3131
3232
Args:
3333
node_dcids (str | List[str]): The DCID(s) of the nodes to query.
34-
expression (str | List[str]): The property or relation expression(s) to query.
34+
expression (str): The property or relation expression(s) to query.
3535
all_pages: If True, fetch all pages of the response. If False, fetch only the first page.
3636
Defaults to True. Set to False to only fetch the first page. In that case, a
3737
`next_token` key in the response will indicate if more pages are available.

datacommons_client/tests/endpoints/test_node_endpoint.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,6 @@ def test_node_endpoint_fetch():
4141
assert "test_node" in response.data
4242

4343

44-
def test_node_endpoint_fetch_list_input():
45-
"""Test the fetch method with list inputs for node_dcids and expression."""
46-
api_mock = MagicMock(spec=API)
47-
api_mock.post.return_value = {
48-
"data": {
49-
"test_node": {
50-
"properties": {
51-
"name": "Test"
52-
}
53-
}
54-
}
55-
}
56-
57-
endpoint = NodeEndpoint(api=api_mock)
58-
response = endpoint.fetch(node_dcids=["test_node1", "test_node2"],
59-
expression=["name", "typeOf"])
60-
61-
api_mock.post.assert_called_once_with(payload={
62-
"nodes": ["test_node1", "test_node2"],
63-
"property": "[name, typeOf]",
64-
},
65-
endpoint="node",
66-
all_pages=True,
67-
next_token=None)
68-
assert isinstance(response, NodeResponse)
69-
assert "test_node" in response.data
70-
71-
7244
def test_node_endpoint_fetch_property_labels():
7345
"""Test fetch_property_labels method."""
7446
api_mock = MagicMock(spec=API)

0 commit comments

Comments
 (0)