-
Notifications
You must be signed in to change notification settings - Fork 227
chore: add mypy #1206
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
chore: add mypy #1206
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
|
|
||
| def _wrap_task(self, key: str, task): | ||
| def wrapped(): | ||
| def _wrap_task(self, key: str, task: Any) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The return type Any is too permissive and doesn't match the actual Callable[[], None] return type of this function
|
|
||
| @functools.wraps(func) | ||
| def wrapper(*args, **kwargs): | ||
| def wrapper(*args: Any, **kwargs: Any) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Missing return value in wrapper function when exception occurs. Should return None explicitly.
| [[tool.mypy.overrides]] | ||
| module = [ | ||
| "langchain.*", | ||
| "openai.*", | ||
| "chromadb.*", | ||
| "tiktoken.*", | ||
| "google.*", | ||
| "anthropic.*", | ||
| "cohere.*", | ||
| "dashscope.*", | ||
| "pymongo.*", | ||
| "bson.*", | ||
| "boto3.*", | ||
| "llama_index.*", | ||
| "respx.*", | ||
| "bs4.*", | ||
| "lark.*", | ||
| "huggingface_hub.*", | ||
| "backoff.*", | ||
| "wrapt.*", | ||
| "packaging.*", | ||
| "requests.*", | ||
| "opentelemetry.*" | ||
| ] | ||
| ignore_missing_imports = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The mypy overrides list is comprehensive but missing type ignores for newer dependencies like langgraph. Add langgraph to the overrides list.
| [[tool.mypy.overrides]] | |
| module = [ | |
| "langchain.*", | |
| "openai.*", | |
| "chromadb.*", | |
| "tiktoken.*", | |
| "google.*", | |
| "anthropic.*", | |
| "cohere.*", | |
| "dashscope.*", | |
| "pymongo.*", | |
| "bson.*", | |
| "boto3.*", | |
| "llama_index.*", | |
| "respx.*", | |
| "bs4.*", | |
| "lark.*", | |
| "huggingface_hub.*", | |
| "backoff.*", | |
| "wrapt.*", | |
| "packaging.*", | |
| "requests.*", | |
| "opentelemetry.*" | |
| ] | |
| ignore_missing_imports = true | |
| [[tool.mypy.overrides]] | |
| module = [ | |
| "langchain.*", | |
| "openai.*", | |
| "chromadb.*", | |
| "tiktoken.*", | |
| "google.*", | |
| "anthropic.*", | |
| "cohere.*", | |
| "dashscope.*", | |
| "pymongo.*", | |
| "bson.*", | |
| "boto3.*", | |
| "llama_index.*", | |
| "respx.*", | |
| "bs4.*", | |
| "lark.*", | |
| "huggingface_hub.*", | |
| "backoff.*", | |
| "wrapt.*", | |
| "packaging.*", | |
| "requests.*", | |
| "opentelemetry.*", | |
| "langgraph.*" | |
| ] | |
| ignore_missing_imports = true |
Important
Add type annotations to functions across multiple files and integrate
mypyfor type checking.client.py,datasets.py,utils.py,environment.py,error_logging.py,prompt_cache.py,serializer.py,CallbackHandler.py,utils.py,media.py,model.py, andopenai.py.Any,Optional,Dict,List,Callable,Union,Literal, andTuple.mypyas a development dependency inpyproject.toml.mypysettings inpyproject.tomlto enforce strict type checking, includingdisallow_untyped_defs,warn_return_any, andstrict_equality.mypyoverrides for specific modules to ignore missing imports.This description was created by
for 150289e. You can customize this summary. It will automatically update as commits are pushed.
Greptile Summary
Disclaimer: Experimental PR review
Adds comprehensive MyPy static type checking support across the langfuse-python codebase, improving type safety and code maintainability without modifying runtime behavior.
pyproject.tomlwith third-party import overrideserror_logging.py