chore(refactor): reduce codebase size and complexity#243
Open
saidsef wants to merge 3 commits into
Open
Conversation
- Collapse verbose multi-paragraph docstrings to single-line summaries - Replace three separate decorator functions (_read_only, _write, _destructive) with a single _annotate() factory - Convert PEP 695 TypedDict type-alias syntax to standard class definitions; pyright now resolves them without reportInvalidTypeForm ignores - Introduce _request() helper to centralise HTTP dispatch, header injection, timeout, and error handling -- removes ~150 lines of duplicated try/except boilerplate across tool methods - Inline _parse_redis_db() into _build_redis_client() - Merge _register_tools() into __init__; make register_tools() default to self.gi when called with no arguments - Guard head SHA key access in add_inline_pr_comment to raise ToolError on a malformed API response instead of a raw KeyError
Add an explicit Release Body Format section with the canonical structure used in published releases: version heading with date, What's Included, optional Breaking Changes and New Environment Variables sections, What Changed commit list, and a Full Changelog comparison link. Rules call out double-dash instead of em-dash, ISO date format, 7-character short SHA, and when to omit optional sections.
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Documentation | 1 minor |
| CodeStyle | 1 minor |
🟢 Metrics -42 complexity
Metric Results Complexity -42
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
- Broaden _request exception catch from httpx.HTTPError to Exception so ValueError from _get_headers() is wrapped in ToolError as before - Change create_pr return type from PRContent to dict[str, Any] to match actual return shape and remove pyright ignore - add_inline_pr_comment already guarded commit_id with .get() + ToolError
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.
What and why
The codebase has grown considerably since initial deployment. This PR trims it back -- removing verbose docstrings, duplicated try/except blocks, and redundant helper functions without changing any externally visible behaviour.
Changes
Source refactoring (
auth,exceptions,github_integration,graphql_client,issues_pr_analyser)_read_only,_write, and_destructivewere three separate functions doing the same thing with different arguments. Replaced with_annotate()factory that produces all three.type Foo = TypedDict(...)aliases (which pyright flagged withreportInvalidTypeForm) to standardclass Foo(TypedDict): .... Type checking is now clean without ignores._request()helper -- every tool method duplicated the same pattern: build URL, callhttpx.{verb}, pass headers and timeout, call_raise_for_status, catchTransportError, wrap inToolError. Centralised into one method; removed roughly 150 lines of boilerplate._parse_redis_db()inlined -- single-purpose private helper with one call site; moved inline._register_tools()removed -- merged into__init__;register_tools()now defaults toself.giwhen called without arguments.add_inline_pr_commentaccessedpr_data["head"]["sha"]directly. A malformed or unexpected API response would raise a rawKeyErrorbypassing FastMCP's error path. Now guarded with.get()and raisesToolErrorwith a clear message.Release skill (
skills/release-management/SKILL.md)Added an explicit Release Body Format section with the canonical structure used in published releases -- heading with date, What's Included, optional Breaking Changes and New Environment Variables sections, What Changed commit list, and Full Changelog comparison link. This gives the LLM a concrete template to follow rather than inventing one each time.
What has not changed