mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 23:13:31 +00:00
core: Put Python version as a project requirement so it is considered by ruff (#26608)
Ruff doesn't know about the python version in `[tool.poetry.dependencies]`. It can get it from `project.requires-python`. Notes: * poetry seems to have issues getting the python constraints from `requires-python` and using `python` in per dependency constraints. So I had to duplicate the info. I will open an issue on poetry. * `inspect.isclass()` doesn't work correctly with `GenericAlias` (`list[...]`, `dict[..., ...]`) on Python <3.11 so I added some `not isinstance(type, GenericAlias)` checks: Python 3.11 ```pycon >>> import inspect >>> inspect.isclass(list) True >>> inspect.isclass(list[str]) False ``` Python 3.9 ```pycon >>> import inspect >>> inspect.isclass(list) True >>> inspect.isclass(list[str]) True ``` Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0f07cf61da
commit
a47b332841
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
import uuid
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Optional
|
||||
from uuid import UUID
|
||||
|
||||
import pytest
|
||||
@@ -16,7 +16,7 @@ from langchain_core.runnables.config import RunnableConfig
|
||||
|
||||
class AsyncCustomCallbackHandler(AsyncCallbackHandler):
|
||||
def __init__(self) -> None:
|
||||
self.events: List[Any] = []
|
||||
self.events: list[Any] = []
|
||||
|
||||
async def on_custom_event(
|
||||
self,
|
||||
@@ -24,8 +24,8 @@ class AsyncCustomCallbackHandler(AsyncCallbackHandler):
|
||||
data: Any,
|
||||
*,
|
||||
run_id: UUID,
|
||||
tags: Optional[List[str]] = None,
|
||||
metadata: Optional[Dict[str, Any]] = None,
|
||||
tags: Optional[list[str]] = None,
|
||||
metadata: Optional[dict[str, Any]] = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
assert kwargs == {}
|
||||
@@ -120,7 +120,7 @@ def test_sync_callback_manager() -> None:
|
||||
|
||||
class CustomCallbackManager(BaseCallbackHandler):
|
||||
def __init__(self) -> None:
|
||||
self.events: List[Any] = []
|
||||
self.events: list[Any] = []
|
||||
|
||||
def on_custom_event(
|
||||
self,
|
||||
@@ -128,8 +128,8 @@ def test_sync_callback_manager() -> None:
|
||||
data: Any,
|
||||
*,
|
||||
run_id: UUID,
|
||||
tags: Optional[List[str]] = None,
|
||||
metadata: Optional[Dict[str, Any]] = None,
|
||||
tags: Optional[list[str]] = None,
|
||||
metadata: Optional[dict[str, Any]] = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
assert kwargs == {}
|
||||
|
Reference in New Issue
Block a user