-
Notifications
You must be signed in to change notification settings - Fork 359
refactor: relocate extract_using_jq and jsonpath_modifier to appropriate modules #1330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 refactors two utility functions (extract_using_jq and jsonpath_modifier) from the config.py module to their actual usage locations, improving code organization and module cohesion. The functions are moved to services/tool_service.py and main.py respectively, where they are actually used.
Key Changes:
- Relocated
extract_using_jqfromconfig.pytoservices/tool_service.pywhere it processes REST tool responses - Relocated
jsonpath_modifierfromconfig.pytomain.pywhere it's used in API endpoints - Updated all import statements and test mocks across the codebase to reflect the new locations
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mcpgateway/config.py | Removed extract_using_jq and jsonpath_modifier functions, cleaned up unused imports, added type hints to __init__ and log_summary |
| mcpgateway/main.py | Added jsonpath_modifier function with complete implementation and necessary imports |
| mcpgateway/services/tool_service.py | Added extract_using_jq function with complete implementation and jq import |
| tests/unit/mcpgateway/test_config.py | Removed tests for relocated functions |
| tests/unit/mcpgateway/test_main.py | Added tests for jsonpath_modifier with new import |
| tests/unit/mcpgateway/services/test_tool_service.py | Added tests for extract_using_jq and updated mock patches |
| tests/fuzz/test_jsonpath_fuzz.py | Updated import path for jsonpath_modifier |
| tests/fuzz/fuzzers/fuzz_jsonpath.py | Updated import path for jsonpath_modifier |
| .pre-commit-config.yaml | Re-enabled Black formatter |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| """Test reading resource content.""" | ||
| # Clear the resource cache to avoid stale/cached values | ||
| from mcpgateway import main as mcpgateway_main | ||
|
|
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The blank line at 695 appears to be an unnecessary addition that doesn't improve readability. Consider removing it to maintain consistency with the original code style.
4389a0c to
832bf71
Compare
|
Leaving this in draft until after #1331 is committed -- that should resolve the last failing test. |
Signed-off-by: Jonathan Springer <jonpspri@gmail.com> Additional linting improvements Signed-off-by: Jonathan Springer <jonpspri@gmail.com> Lots of cleanup of secrets in code Signed-off-by: Jonathan Springer <jonpspri@gmail.com> fix: Correct Flake8 docstring errors in config.py - Remove type annotations from parameter docstrings (DAR103) - Add missing Raises sections for ValueError exceptions (DAR401) - Fix return type descriptions to match TypedDict types (DAR203) Resolves all DAR (docstring argument/return) validation errors. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Jonathan Springer <jonpspri@gmail.com>
4c58367 to
c12599d
Compare
Summary
Refactored two utility functions from
config.pyto their appropriate usage locations, improving module cohesion and reducing the scope of the configuration module.Functions relocated:
extract_using_jq:config.py→services/tool_service.pyjsonpath_modifier:config.py→main.pyBenefits
Settings.__init__andSettings.log_summaryChanges
Code Movement
extract_using_jqwith all docstring examples and error handlingjsonpath_modifierwith complete implementation and docstringsTest Coverage
extract_using_jqtests fromtest_config.py→test_tool_service.pyjsonpath_modifiertests fromtest_config.py→test_main.pyfuzz_jsonpath.pyandtest_jsonpath_fuzz.pyAdditional Improvements
__init__(self, **kwargs: Any) -> Nonelog_summary(self) -> NoneTesting
All existing tests pass with updated imports:
Test Plan
pytest tests/unit/mcpgateway/test_config.pypytest tests/unit/mcpgateway/test_main.pypytest tests/unit/mcpgateway/services/test_tool_service.pypytest tests/fuzz/test_jsonpath_fuzz.py