Skip to content

refactor: Fix type annotation errors and remove unused code #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakekasan
Copy link

This change fixes annoying LSP diagnostic errors when using this library and pyright/basedpyright is set to strict mode.

The main issue was that the overloads for methods with a stream option were incorrect and confused the LSP. Also removes a function that was never used.

@ParthSareen ParthSareen self-requested a review August 6, 2025 19:43
Copy link
Member

@ParthSareen ParthSareen left a comment

Choose a reason for hiding this comment

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

Looks good for the most part :) Will test before approving

def __init__(
self,
client,
client: Type[CT],
Copy link
Member

Choose a reason for hiding this comment

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

What LSP are you using which is giving you the annotation errors?

Copy link
Author

Choose a reason for hiding this comment

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

Basedpyright with typeCheckingMode = "strict" in the settings. This specific error popped up when I had the actual ollama-python project open, not when I was just using ollama-python in another project. It caused a lot of other LSP diagnostic errors because most methods of Client and AsyncClient just wrap _client, so it being untyped meant that everything else was as well.

To be honest, there probably is a more elegant way to annotate this using ParamSpec and all that but that looked like a pretty deep rabbit hole... 😅

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.

2 participants