Skip to content

Python version: updating pyproject and uv lock to python 3.12#406

Merged
nishika26 merged 8 commits intomainfrom
bug/python_version
Nov 5, 2025
Merged

Python version: updating pyproject and uv lock to python 3.12#406
nishika26 merged 8 commits intomainfrom
bug/python_version

Conversation

@nishika26
Copy link
Collaborator

@nishika26 nishika26 commented Oct 14, 2025

Summary

Target issue is #384

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

  • Updated runtime requirement to Python 3.12.
  • Updated all the other imports as well such as fastapi, when you run "fastapi run --reload app/main.py" what will come up will look a little different than before
  • Aligned tooling to target Python 3.12.
  • Pinned langfuse's dependency version to let the current code of langfuse run without any issue, note that an issue to update langfuse to v3 and making changes in the rest of the code according to the changes made in langfuse v3, will be made
  • Removed "configure_langfuse" function from utils because it is not being used anywhere
  • No user-visible behavior changes.

Summary by CodeRabbit

  • Chores

    • Updated minimum Python requirement to 3.12 and tool target to match.
    • Pinned a third‑party dependency to a specific version for stability.
    • Removed redundant internal integrations and imports.
  • Improvements

    • Enhanced error handling for clearer diagnostic messages.
    • Added optional runtime client retrieval to better handle external integrations when available.

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Walkthrough

Removed unused Langfuse imports from an API route, deleted the configure_langfuse helper, added get_langfuse_client in utils, refined OpenAI error handling, a no-op import tweak in Langfuse core, and updated project metadata (Python -> 3.12, pinned langfuse, Ruff target).

Changes

Cohort / File(s) Summary
API route cleanup
backend/app/api/routes/threads.py
Removed imports of observe and langfuse_context from langfuse.decorators; no behavioral changes.
Langfuse core import noop
backend/app/core/langfuse/langfuse.py
Minor import line adjustment (redundant import replaced with identical import); no functional change.
Utilities: remove Langfuse config
backend/app/core/util.py
Deleted configure_langfuse(credentials: dict) -> tuple[Langfuse, bool] and related Langfuse setup; configure_openai left unchanged.
Utilities: add Langfuse client helper & error handling
backend/app/utils.py
Added get_langfuse_client(session, org_id, project_id) returning a configured Langfuse client when credentials include public_key, secret_key, and host; enhanced handle_openai_error to extract messages from multiple error shapes; added Langfuse import.
Project configuration updates
backend/pyproject.toml
Bumped Python requires-python to >=3.12,<4.0; pinned langfuse to ==2.60.3; updated Ruff target-version to py312.

Sequence Diagram(s)

sequenceDiagram
  participant API as API / caller
  participant Utils as utils.get_langfuse_client
  participant DB as provider credential store
  participant LF as Langfuse client

  note over Utils,DB: New helper fetches credentials and constructs client
  API->>Utils: request Langfuse client (session, org_id, project_id)
  Utils->>DB: get_provider_credential(session, org_id, project_id)
  alt credentials include public_key, secret_key, host
    Utils->>LF: Langfuse(public_key, secret_key, host) [configure]
    LF-->>Utils: Langfuse client
    Utils-->>API: return client
  else missing/invalid credentials
    Utils-->>API: return None
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check for any remaining references to the removed configure_langfuse (calls or imports).
  • Validate get_langfuse_client credential lookup and edge cases (missing keys, host formats).
  • Confirm OpenAI error-handling branches correctly handle varied exception shapes.
  • Verify CI and runtime implications of requires-python bump and pinned langfuse version.

Poem

I nibble through imports in the night,
Hopped out a function, left the burrow light.
A helper arrives to fetch the key,
Configs refreshed — 3.12 for me!
Tail twitch, carrot cheer, the code hops on with glee 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title focuses on Python version upgrade and updating config files, but the changeset includes significant code refactoring (removing Langfuse integration, adding new utility functions) that goes beyond version updates. Consider a more comprehensive title like 'Upgrade Python to 3.12 and refactor Langfuse integration' to reflect all major changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/python_version

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.

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/utils.py 28.57% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@nishika26 nishika26 marked this pull request as ready for review October 15, 2025 09:47
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
backend/app/core/langfuse/langfuse.py (1)

5-5: Remove the no-op import change.

This line appears to have been removed and re-added without any actual change. This creates unnecessary noise in the PR diff and complicates code review.

If this was unintentional, revert the change. If it was due to a formatter, consider running formatting tools consistently before committing.

backend/pyproject.toml (1)

30-30: Consider loosening the langfuse version pin (backend/pyproject.toml:30)
Pinning ==2.60.3 blocks patch/minor updates. Prefer >=2.60.3,<3.0.0. If an exact pin is required, document why, note that no advisories exist for 2.60.3, and schedule periodic reviews.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 692b3ea and 2ecdfd6.

⛔ Files ignored due to path filters (1)
  • backend/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • backend/app/api/routes/threads.py (0 hunks)
  • backend/app/core/langfuse/langfuse.py (1 hunks)
  • backend/app/core/util.py (1 hunks)
  • backend/pyproject.toml (3 hunks)
💤 Files with no reviewable changes (1)
  • backend/app/api/routes/threads.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use type hints in Python code (Python 3.11+ project)

Files:

  • backend/app/core/util.py
  • backend/app/core/langfuse/langfuse.py
backend/app/core/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Place core functionality (config, DB session, security, exceptions, middleware) in backend/app/core/

Files:

  • backend/app/core/util.py
  • backend/app/core/langfuse/langfuse.py
backend/app/core/langfuse/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Place Langfuse observability integration under backend/app/core/langfuse/

Files:

  • backend/app/core/langfuse/langfuse.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks (3.11.7, 6)
🔇 Additional comments (3)
backend/pyproject.toml (2)

62-62: Ruff target version alignment looks correct.

The update from py310 to py312 aligns with the Python version requirement change, assuming the Python 3.12 upgrade is validated and intentional.

Note: This approval is conditional on the Python 3.12 upgrade being properly validated (see comments on line 5).


5-5: Verify Python 3.12 upgrade

No Python 3.12–specific syntax detected, but raising the runtime requirement from 3.11 to 3.12 is breaking. Please verify:

  • All dependencies and environments support Python 3.12
  • The full test suite passes on Python 3.12
  • CI, Docker, and deployment configurations are updated to use Python 3.12
  • The PR description documents why Python 3.12 is required
backend/app/core/util.py (1)

8-10: Remove unused Langfuse import and commented-out code

The Langfuse import on line 8 isn’t referenced elsewhere; delete it and the commented-out import.

-from langfuse import Langfuse
-# from langfuse import langfuse_context

@nishika26 nishika26 self-assigned this Oct 15, 2025
@nishika26 nishika26 added bug Something isn't working ready-for-review labels Oct 15, 2025
@nishika26 nishika26 linked an issue Oct 15, 2025 that may be closed by this pull request
@nishika26 nishika26 changed the title updating pyproject and uv lock to python 3.12 Python version: updating pyproject and uv lock to python 3.12 Oct 15, 2025
@nishika26 nishika26 requested review from AkhileshNegi and removed request for avirajsingh7 October 15, 2025 09:59
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0b8e49 and 0862dac.

📒 Files selected for processing (1)
  • backend/app/utils.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use type hints in Python code (Python 3.11+ project)

Files:

  • backend/app/utils.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: ProjectTech4DevAI/ai-platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T12:05:01.317Z
Learning: Applies to backend/app/core/langfuse/**/*.py : Place Langfuse observability integration under backend/app/core/langfuse/
📚 Learning: 2025-10-08T12:05:01.317Z
Learnt from: CR
Repo: ProjectTech4DevAI/ai-platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T12:05:01.317Z
Learning: Applies to backend/app/core/langfuse/**/*.py : Place Langfuse observability integration under backend/app/core/langfuse/

Applied to files:

  • backend/app/utils.py
🧬 Code graph analysis (1)
backend/app/utils.py (1)
backend/app/crud/credentials.py (1)
  • get_provider_credential (121-159)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks (3.11.7, 6)

@nishika26 nishika26 merged commit 48ca3b2 into main Nov 5, 2025
2 of 3 checks passed
@nishika26 nishika26 deleted the bug/python_version branch November 5, 2025 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python version mismatch

3 participants