Skip to content

feat: add type hints to TextData and forget module#3081

Open
jasoncobra3 wants to merge 6 commits into
topoteretes:devfrom
jasoncobra3:feat/add-type-hints-textdata-forget
Open

feat: add type hints to TextData and forget module#3081
jasoncobra3 wants to merge 6 commits into
topoteretes:devfrom
jasoncobra3:feat/add-type-hints-textdata-forget

Conversation

@jasoncobra3

Copy link
Copy Markdown

Closes #2681

What changed

cognee/modules/ingestion/data_types/TextData.py

  • create_text_data()-> "TextData"
  • get_identifier()-> str
  • get_metadata()-> dict
  • ensure_metadata()-> None
  • get_data()-> AsyncGenerator[str, None]
  • Added dict annotation to metadata class variable

cognee/api/v1/forget/forget.py

  • Added user: Any to all 7 functions to avoid circular
    imports while providing an explicit typing signal
  • Added Any to existing typing imports

Notes

  • No logic changes made anywhere — purely additive
  • user: Any was chosen over importing the User model
    directly to avoid circular dependency issues
  • ruff check passes on both files

Part of

This is a small focused first step toward #2681
enforcing type hints gradually across the codebase.
Happy to continue with more files if maintainers
want to keep the momentum going!

Vasilije1990 and others added 6 commits May 30, 2026 20:08
## Summary
- Merge current dev into main for v1.1.2
- Includes the public Cognee frontend sync and CLI UI release assets
- Includes the Postgres neighborhood seed cast fix and usage logger e2e
retry workflow update

## Release notes
After this merges, run .github/workflows/release.yml on main to publish
the main release and latest Docker tag.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added conversation-driven search with history sidebar and per-message
dataset tracking.
* Introduced "Brains" browser with document management, file uploads,
and drag-and-drop support.
* Added knowledge graph customization: select/assign graph models,
generate/edit custom extraction prompts, and upload/manage ontologies.
* Enhanced agent connection with tab-based onboarding and modal-driven
setup flows.
* Added mascot animation feedback throughout the app for loading states.

* **Improvements**
  * Rebranded terminology: "Dataset" → "Brain" across the application.
* Redesigned connections page with agent permission modeling and sharing
workflows.
* Integrated analytics event tracking for user interactions across major
flows.
* Enhanced API Keys management with tenant access controls and
analytics.
* Improved dashboard with updated metrics, activity feed, and embedded
search.

* **Bug Fixes**
* Fixed PostgreSQL graph adapter seed parameter casting for proper
neighborhood queries.

* **Chores**
  * Bumped version to 1.1.2.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/topoteretes/cognee/pull/2935?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Updated the README to clarify Cognee's purpose and features, emphasizing its role as an open-source AI memory platform for agents. Enhanced descriptions of data ingestion, knowledge graph, and cognitive science approaches.
In API mode (--api-url, remote backend) cognify_status was non-functional:
it resolved the dataset via local get_default_user()/get_unique_dataset_id()
(SQLite, absent in the MCP process) and get_pipeline_status() raised
NotImplementedError. On main this surfaced as "not available in API mode";
on 0.5.4 it crashed with sqlite3.OperationalError.

Resolve the dataset id over HTTP via list_datasets() and read status from
the existing GET /api/v1/datasets/status endpoint. Direct mode is unchanged.

Re-lands the fix from topoteretes#2418, which was closed unmerged and not carried by
the superseding topoteretes#2459.
…etes#3068)

## Summary

Makes the MCP `cognify_status` tool work in **API mode** (`cognee-mcp
--api-url ...`, remote backend). Today it is non-functional there:

- On `main`: returns `❌ Pipeline status is not available in API mode`.
- On released 0.5.4: crashes with `sqlite3.OperationalError: unable to
open database file`.

Fixes topoteretes#3067.

## Root cause

`cognify_status` depended on a local cognee install even in API mode:

- `server.py` resolved the dataset via `get_default_user()` /
`get_unique_dataset_id()` (local SQLite, absent in the MCP process).
- `cognee_client.get_pipeline_status()` hard-stopped in API mode with
`raise NotImplementedError("Pipeline status is not available via API")`.

The endpoint the original `NotImplementedError` comment asked for
already exists: `GET /api/v1/datasets/status?dataset=<id>` →
`{dataset_id: PipelineRunStatus}`.

## Changes

- **`cognee-mcp/src/cognee_client.py`** — `get_pipeline_status()`: in
API mode, call `GET /api/v1/datasets/status` (one `dataset` query param
per id) and return the parsed `{dataset_id: status}` map instead of
raising.
- **`cognee-mcp/src/server.py`** — `cognify_status()`: in API mode,
resolve the dataset id via `list_datasets()` (HTTP), then fall through
to the existing single-/multi-pipeline status logic. Returns a clear
"dataset not found" message when the name is unknown. Direct mode is
unchanged.

## History

This re-lands topoteretes#2418 (`fix(mcp): cognify_status works in API mode via
REST endpoint`), which was closed unmerged and was **not** carried by
the superseding topoteretes#2459 (that PR added the dataset/`pipelines` parameters
but left the API-mode path raising). The fix is rebased onto the current
`main` handler, so it preserves the `pipelines` selection and
agent-scoped default dataset behavior.

## Testing

Verified end-to-end against a live cognee 1.x server: the patched MCP
boots in API mode and `cognify_status` returns real status
(`{"<dataset-id>": "DATASET_PROCESSING_STARTED"}`, `isError: false`)
where upstream returned the "not available" message.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes topoteretes#2681

Added Python type hints to function parameters and return
types in two modules as part of the gradual type enforcement
effort:

- cognee/modules/ingestion/data_types/TextData.py
  Added return types to all methods: get_identifier() -> str,
  get_metadata() -> dict, ensure_metadata() -> None,
  get_data() -> AsyncGenerator[str, None]
  Added TextData return type to create_text_data()
  Added dict annotation to metadata class variable

- cognee/api/v1/forget/forget.py
  Added user: Any type to all 7 functions to avoid circular
  imports while providing explicit typing signal
  Added Any to existing typing imports

No logic changes made. ruff check passes on both files.
@github-actions

Copy link
Copy Markdown
Contributor

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

@Vasilije1990 Vasilije1990 changed the base branch from main to dev June 17, 2026 06:45
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.

[Feature]: Enforce type hints and gradually fix/add types

3 participants