Skip to content

feat: add return type hints to API endpoint functions#2072

Merged
Vasilije1990 merged 2 commits intotopoteretes:devfrom
allenjoseph05:fix/add-return-type-hints-2043
Feb 6, 2026
Merged

feat: add return type hints to API endpoint functions#2072
Vasilije1990 merged 2 commits intotopoteretes:devfrom
allenjoseph05:fix/add-return-type-hints-2043

Conversation

@allenjoseph05
Copy link

@allenjoseph05 allenjoseph05 commented Jan 30, 2026

Description

Adds missing return type hints to API endpoint functions as specified in issue #2043.

Changes Made

  • Added return type hints to 7 functions across 5 files:
    • classify() in cognee/modules/ingestion/classify.pyUnion[TextData, BinaryData, S3BinaryData]
    • delete(), delete_single_document(), delete_document_subgraph() in cognee/api/v1/delete/delete.pydict
    • update() in cognee/api/v1/update/update.pyAny
    • visualization_server() in cognee/api/v1/visualize/start_visualization_server.pycallable
    • visualize_graph() in cognee/api/v1/visualize/visualize.pyAny
  • Note: ui.py functions already had return type hints

Testing

  • Verified all functions have type hints using verification script
  • Code follows Python typing conventions
  • Pre-commit hooks passed (formatting applied)
  • All existing functionality preserved

Related Issue

Fixes #2043

Summary by CodeRabbit

  • Refactor
    • Enhanced code quality with improved type annotations across API functions for better maintainability and code clarity.

✏️ Tip: You can customize this high-level summary in your review settings.

@pull-checklist
Copy link

Please make sure all the checkboxes are checked:

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have added end-to-end and unit tests (if applicable).
  • I have updated the documentation and README.md file (if necessary).
  • I have removed unnecessary code and debug statements.
  • PR title is clear and follows the convention.
  • I have tagged reviewers or team members for feedback.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Walkthrough

Add return type annotations to five API endpoint and utility functions across delete, update, visualize, and ingestion modules to improve type safety and IDE autocompletion. Functions now explicitly declare return types as dict, Any, callable, or Union types matching their actual return values.

Changes

Cohort / File(s) Summary
Delete API Functions
cognee/api/v1/delete/delete.py
Added return type annotations (-> dict) to three public async functions: delete(), delete_single_document(), and delete_document_subgraph().
Update API Function
cognee/api/v1/update/update.py
Added return type annotation (-> Any) to the update() function.
Visualize API Functions
cognee/api/v1/visualize/start_visualization_server.py, cognee/api/v1/visualize/visualize.py
Added return type annotations to visualization_server() (-> callable) and visualize_graph() (-> Any). Added import for Any from typing module.
Ingestion Classify Function
cognee/modules/ingestion/classify.py
Added return type annotation (-> Union[TextData, BinaryData, S3BinaryData]) to the classify() function.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

run-checks

Suggested reviewers

  • pazone
  • hajdul88
  • siillee
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding return type hints to API endpoint functions, which matches the changeset.
Description check ✅ Passed The description adequately covers the changes, lists affected functions with their return types, documents testing performed, and links to the related issue.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #2043: type hints added to all 7 specified functions with appropriate return types that match actual return values.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding return type hints to the functions specified in issue #2043; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello @allenjoseph05, thank you for submitting a PR! We will respond as soon as possible.

@Vasilije1990
Copy link
Contributor

@allenjoseph05 please check CONTRIBUTING.md and open a PR against dev branch + upload the screenshot of tests passing locally

@allenjoseph05
Copy link
Author

Hi @Vasilije1990,

I've completed the type hint additions for all functions listed in the issue. However, I wanted to address the testing requirement mentioned in CONTRIBUTING.md.

I attempted to run cognee/tests/test_library.py locally but encountered OpenAI API quota limitations (my account has insufficient credits). Since this is a type annotations-only change with zero functional modifications, I wanted to explain my testing approach:

What I verified locally:
Pre-commit hooks (ruff format, ruff check) - all passed
Python syntax validation - all files parse correctly
Import verification - all modified modules import successfully
Type annotations are syntactically correct

@Vasilije1990
Copy link
Contributor

@allenjoseph05 understood. We will merge it then, but please open against dev branch, not main

@Vasilije1990 Vasilije1990 changed the base branch from main to dev February 6, 2026 06:04
@gitguardian
Copy link

gitguardian bot commented Feb 6, 2026

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9573981 Triggered Generic Password 92d6a06 .github/workflows/examples_tests.yml View secret
8719688 Triggered Generic Password 92d6a06 .env.template View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@Vasilije1990 Vasilije1990 merged commit 2cf9e1a into topoteretes:dev Feb 6, 2026
2 of 3 checks passed
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.

Add missing return type hints to API endpoint functions

2 participants