Skip to content

chore(refactor): reduce codebase size and complexity#243

Open
saidsef wants to merge 3 commits into
mainfrom
chore/reduce-codebase-complexity
Open

chore(refactor): reduce codebase size and complexity#243
saidsef wants to merge 3 commits into
mainfrom
chore/reduce-codebase-complexity

Conversation

@saidsef
Copy link
Copy Markdown
Owner

@saidsef saidsef commented May 17, 2026

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)

  • Docstrings -- multi-paragraph docstrings replaced with single-line summaries. The implementation speaks for itself; lengthy argument tables added noise.
  • Decorator consolidation -- _read_only, _write, and _destructive were three separate functions doing the same thing with different arguments. Replaced with _annotate() factory that produces all three.
  • TypedDict syntax -- changed from PEP 695 type Foo = TypedDict(...) aliases (which pyright flagged with reportInvalidTypeForm) to standard class Foo(TypedDict): .... Type checking is now clean without ignores.
  • _request() helper -- every tool method duplicated the same pattern: build URL, call httpx.{verb}, pass headers and timeout, call _raise_for_status, catch TransportError, wrap in ToolError. 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 to self.gi when called without arguments.
  • Bug fix -- add_inline_pr_comment accessed pr_data["head"]["sha"] directly. A malformed or unexpected API response would raise a raw KeyError bypassing FastMCP's error path. Now guarded with .get() and raises ToolError with 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

  • All public tool signatures are identical
  • HTTP behaviour, timeouts, and error types are unchanged
  • Auth flows (API key and OAuth2) are unchanged
  • Redis and JWT key derivation logic is unchanged

saidsef added 2 commits May 17, 2026 12:19
- 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.
@saidsef saidsef added documentation Improvements or additions to documentation chore maintenance refactoring labels May 17, 2026
@saidsef saidsef self-assigned this May 17, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 17, 2026

Up to standards ✅

🟢 Issues 2 minor

Results:
2 new issues

Category Results
Documentation 1 minor
CodeStyle 1 minor

View in Codacy

🟢 Metrics -42 complexity

Metric Results
Complexity -42

View in Codacy

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 17, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

github-actions[bot]
github-actions Bot previously approved these changes May 17, 2026
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore documentation Improvements or additions to documentation maintenance refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant