add fix for JSON passing into query method, add tests#27
Open
sierra-moxon wants to merge 3 commits intomainfrom
Open
add fix for JSON passing into query method, add tests#27sierra-moxon wants to merge 3 commits intomainfrom
sierra-moxon wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
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 toFalseso it returns adictby default. - Updated
query()’s parameter type hint and docstring to reflect that it expects adict.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build_querywas defaulting toreturn_json=True, returning a JSON string. But query() passes its input directly to requests, which expects a dict. This changesbuild_queryto default toreturn_json=Falseand 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.