Skip to content

Improve context provider functions in llm_context.py - #31

Merged
DevSidd2006 merged 2 commits into
DevSidd2006:mainfrom
leenacags:patch-1
Oct 28, 2026
Merged

DevSidd2006 merged 2 commits into
DevSidd2006:mainfrom
leenacags:patch-1

Conversation

@leenacags

@leenacags leenacags commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Refactor context provider functions for clarity and type hints.

Description

Please include a summary of the change and which issue it fixes. Include relevant motivation and context.

Fixes #30

Screenshots (if visual change)

For any UI/visual change, add before & after screenshots or a short GIF.

Before After

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring / Code cleanup

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions so we can reproduce.

  • Automated tests run locally (pytest tests/ -v)
  • Tested in mock mode without external API keys (LLM_PROVIDER=mock)
  • UI tested across pages/ (if applicable)

Checklist:

  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes
  • I have not committed any secrets, API keys, credentials, or personal candidate data
  • AI tools are welcome, but I've reviewed and verified all AI-assisted content myself
  • For visual/UI changes, I've included before/after screenshots or a GIF above

Summary by Sourcery

Enhancements:

  • Clarify context provider lifecycle documentation and add precise generic type hints for provider context tokens.

Refactor context provider functions for clarity and type hints.
@sourcery-ai

sourcery-ai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This refactor keeps ContextVar-based provider resolution unchanged while making the helper functions clearer through concise documentation, improved token typing, and minor formatting cleanup.

File-Level Changes

Change Details Files
Refine context provider API documentation and typing without changing runtime behavior.
  • Add a generic return type to the context-setting token.
  • Simplify and clarify docstrings for setting, resetting, and retrieving providers.
  • Format the public export list for readability.
  • Remove the module-level explanatory design commentary.
core/llm_context.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

👋 Thanks for opening this PR! A maintainer will review it soon.

In the meantime, please make sure you've read CONTRIBUTING.md and filled out the PR template, including screenshots for any visual changes.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="core/llm_context.py" line_range="1-24" />
<code_context>
-"""The ContextVar seam BYOK uses to reach get_llm_provider() (providers/llm/__init__.py)
</code_context>
<issue_to_address>
**nitpick:** Removing the module-level docstring makes `core.llm_context.__doc__` become `None`, so generated API documentation and introspection tools lose the ContextVar lifecycle and request-boundary guidance that this module previously exposed.

**Triggers:** When documentation tooling or runtime introspection reads `core.llm_context.__doc__`.

**Suggested fix:** Retain the module-level docstring while shortening or updating it as needed.
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread core/llm_context.py Resolved

@DevSidd2006 DevSidd2006 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

How this will affect the codebase?

@DevSidd2006
DevSidd2006 merged commit 0708e01 into DevSidd2006:main Oct 28, 2026
5 of 6 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Thanks for the contribution, @leenacags! This PR has been merged. We appreciate you helping improve OpenHire.

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.

fix: improve ContextVar provider typing

2 participants