Skip to content

refactor: move Notion client to app/services/#945

Merged
muddlebee merged 5 commits intoTracer-Cloud:mainfrom
gitsofaryan:refactor/move-notion-client
Apr 29, 2026
Merged

refactor: move Notion client to app/services/#945
muddlebee merged 5 commits intoTracer-Cloud:mainfrom
gitsofaryan:refactor/move-notion-client

Conversation

@gitsofaryan
Copy link
Copy Markdown
Contributor

@gitsofaryan gitsofaryan commented Apr 25, 2026

Fixes #898

Describe the changes you have made in this PR -

Relocated the Notion API client to a more consistent location under app/services/ while ensuring backward compatibility for existing imports.

  • Moved app/integrations/clients/notion/client.py to app/services/notion/client.py.
  • Added app/services/notion/__init__.py to ensure the new directory is treated as a proper Python package and exports the client/config.
  • Updated app/integrations/clients/notion/__init__.py to import NotionClient and NotionConfig from the new services path, preventing breakage for any code using the old package-level import.
  • Updated tests/integrations/test_notion_client.py to use the new canonical path and strengthened the identity assertion in the compatibility test.
  • Updated .cursor/rules/integrations.mdc to reflect the correct directory structure and instructions for new clients.

Demo/Screenshot for feature changes and bug fixes -

Ran the Notion client tests locally:

tests/integrations/test_notion_client.py::test_is_configured PASSED      [ 20%]
tests/integrations/test_notion_client.py::test_is_not_configured_missing_key PASSED [ 40%]
tests/integrations/test_notion_client.py::test_create_investigation_page_success PASSED [ 60%]
tests/integrations/test_notion_client.py::test_create_investigation_page_http_error PASSED [ 80%]
tests/integrations/test_notion_client.py::test_notion_compatibility_import PASSED [100%]

============================== 5 passed in 1.15s ==============================

Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • Yes, I used AI assistance (Antigravity)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:
The move follows the established pattern of other service clients (Grafana, Datadog) already present in app/services/. I addressed Greptile review findings by adding the missing __init__.py in the new location and strengthening the compatibility test to use object identity assertions. Additionally, I updated the Cursor rules in integrations.mdc to correctly document this pattern for future contributors.


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

@gitsofaryan
Copy link
Copy Markdown
Contributor Author

cc : @VaibhavUpreti @rrajan94 PTAL!

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 25, 2026

Greptile Summary

This PR relocates the Notion API client from app/integrations/clients/notion/client.py to app/services/notion/client.py and adds a backward-compatibility re-export in the old __init__.py, with the test file updated to use the new canonical path.

  • Missing app/services/notion/__init__.py: every other service sub-package (grafana, jira, datadog, etc.) ships an __init__.py; its absence makes this a namespace package and risks mypy not discovering the module, breaking make typecheck.

Confidence Score: 4/5

Safe to merge after adding the missing app/services/notion/init.py to keep the package consistent with the rest of the codebase.

One P1 finding: the new app/services/notion/ directory is missing an init.py, diverging from every other service package and risking mypy and import-mode failures. Remaining findings are P2 (weak compatibility test assertion, undocumented convention change). Score is 4 pending the missing init file.

app/services/notion/ — needs an init.py added to match the pattern of every other service sub-package.

Important Files Changed

Filename Overview
app/services/notion/client.py Renamed from integrations/clients/notion/client.py; code is unchanged but the new package directory is missing its init.py, inconsistent with every other service sub-package.
app/integrations/clients/notion/init.py Re-exports NotionClient and NotionConfig from the new canonical path; backward-compatibility shim is correct and all is properly declared.
tests/integrations/test_notion_client.py Updated to import from new path; new compatibility test is present but only checks non-None rather than asserting object identity.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["app.integrations.clients.notion\n__init__.py (compat shim)"] -->|re-exports| B["app.services.notion.client\nNotionClient / NotionConfig"]
    C["tests/integrations/\ntest_notion_client.py"] -->|canonical import| B
    C -->|compatibility import| A
    D["Any existing caller\nusing old path"] -->|still works via| A
Loading

Comments Outside Diff (1)

  1. app/services/notion/client.py, line 1 (link)

    P1 Missing __init__.py for the new package

    app/services/notion/ has no __init__.py, making it a namespace package. Every other service sub-package in this repo (alertmanager, coralogix, datadog, eks, elasticsearch, google_docs, grafana, honeycomb, jira, opsgenie, tracer_client, vercel) includes one. Mypy's package discovery and some pytest import modes rely on regular packages; the absence here will cause mypy app/ to potentially miss this module or raise Cannot find implementation or library stub errors on the re-export in app/integrations/clients/notion/__init__.py.

Reviews (1): Last reviewed commit: "refactor: move Notion client to app/serv..." | Re-trigger Greptile

Comment thread tests/integrations/test_notion_client.py Outdated
Comment thread app/integrations/clients/notion/__init__.py
@gitsofaryan
Copy link
Copy Markdown
Contributor Author

cc : @VaibhavUpreti @rrajan94 PTAL!

Copy link
Copy Markdown
Collaborator

@yashksaini-coder yashksaini-coder left a comment

Choose a reason for hiding this comment

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

The code migration itself is solid — correct destination, shim pattern works, identity assertion in the compatibility test is the right approach. One doc fix needed before this merges.

.cursor/rules/integrations.mdc — incomplete directory tree

The PR removes the clients/ section from the diagram entirely, but app/integrations/clients/prefect/ still exists and was not migrated. A contributor (or AI coding assistant) reading these rules would incorrectly assume all clients now live under app/services/ and might put new work in the wrong place, or be confused when they encounter prefect.

Please update the tree in .cursor/rules/integrations.mdc to:

app/services/
├── grafana/          # Vendor-specific client packages
├── datadog/
├── s3_client.py      # Single-file clients
└── vercel/
app/integrations/
├── clients/
│   └── prefect/      # Legacy location — new clients go in app/services/
├── opensre_mcp.py    # MCP server implementation
└── ...

That's the only change needed. Everything else — the client move, the shim, the test update — is good to go.

@gitsofaryan
Copy link
Copy Markdown
Contributor Author

@yashksaini-coder addressed the changes!

@gitsofaryan
Copy link
Copy Markdown
Contributor Author

@VaibhavUpreti @muddlebee PTAL!

Copy link
Copy Markdown
Collaborator

@muddlebee muddlebee left a comment

Choose a reason for hiding this comment

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

LGTM

├── grafana/ # Vendor-specific client packages
├── datadog/
├── s3_client.py # Single-file clients
└── vercel/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just add a newline here like btw app/services/ and app/integrations/

app/services/
├── grafana/
├── datadog/
├── s3_client.py
└── vercel/

app/integrations/
├── clients/
│ └── prefect/ # Legacy location — new clients go in app/services/
├── opensre_mcp.py
└── ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

resolve above then ready to merge

@gitsofaryan
Copy link
Copy Markdown
Contributor Author

@muddlebee done ser!

@muddlebee muddlebee merged commit d7c6888 into Tracer-Cloud:main Apr 29, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

💜 One more reason the project grows. Thanks @gitsofaryan — your contribution just landed!


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

@muddlebee
Copy link
Copy Markdown
Collaborator

🚀 good going @gitsofaryan nice work so far

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.

Move the Notion client under app/services/ and keep compatibility imports

3 participants