Skip to content

add fix for JSON passing into query method, add tests#27

Open
sierra-moxon wants to merge 3 commits intomainfrom
predicate_query
Open

add fix for JSON passing into query method, add tests#27
sierra-moxon wants to merge 3 commits intomainfrom
predicate_query

Conversation

@sierra-moxon
Copy link
Copy Markdown
Member

build_query was defaulting to return_json=True, returning a JSON string. But query() passes its input directly to requests, which expects a dict. This changes build_query to default to return_json=False and updates query()'s type hint from str to dict to match what it needs. The return_json=True option still works if you need a JSON string for something else.

Added tests covering the default return type, query structure, and that build_query's output type matches query's expected input.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a mismatch between build_query()’s default return type and what query() passes to requests.post(..., json=...), by making the default query payload a Python dict instead of a JSON string.

Changes:

  • Changed build_query(..., return_json=...) default to False so it returns a dict by default.
  • Updated query()’s parameter type hint and docstring to reflect that it expects a dict.
Comments suppressed due to low confidence (1)

TCT/trapi.py:50

  • The build_query docstring now says the default return is a dict, but the example still shows (and quotes) a JSON/string-like return. Please update the example to either show a dict return value or call build_query(..., return_json=True) so the docs match the new default behavior.
    A dict (default) or json string if return_json=True

    Examples
    --------
    In this example, we want all genes that physically interact with gene 3845.
    >>> build_query(['NCBIGene:3845'], ['biolink:Gene'], ['biolink:physically_interacts_with'])

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants