Skip to content

chore: Bump mypy version to 1.20 in core, langchain_v1, text-splitters and standard-tests#36470

Open
Christophe Bornet (cbornet) wants to merge 1 commit intolangchain-ai:masterfrom
cbornet:mypy-1.20
Open

chore: Bump mypy version to 1.20 in core, langchain_v1, text-splitters and standard-tests#36470
Christophe Bornet (cbornet) wants to merge 1 commit intolangchain-ai:masterfrom
cbornet:mypy-1.20

Conversation

@cbornet
Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions github-actions bot added core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) infra PRs made that include chores, devops, repo meta changes langchain `langchain` package issues & PRs size: XS < 50 LOC standard-tests Related to the package `standard-tests` text-splitters Related to the package `text-splitters` labels Apr 2, 2026
@org-membership-reviewer org-membership-reviewer bot added trusted-contributor >= 5 merged PRs in the `langchain-ai/langchain` repo external labels Apr 2, 2026
@cbornet Christophe Bornet (cbornet) changed the title chore: Bump mypy version to 1.20 chore: Bump mypy version to 1.20 in core, langchain_v1, text-splitters and standard-tests Apr 2, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 2, 2026

Merging this PR will not alter performance

✅ 13 untouched benchmarks
🆕 2 new benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 Simulation test_create_agent_instantiation_with_middleware N/A 14.9 ms N/A
🆕 Simulation test_create_agent_instantiation N/A 4.1 ms N/A

Comparing cbornet:mypy-1.20 (6cb4977) with master (cfb16f6)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (c59e83a) during the generation of this report, so cfb16f6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@mdrxy
Copy link
Copy Markdown
Member

I think a more compelling change here would be switching from mypy to ty, FWIW

@cbornet
Copy link
Copy Markdown
Collaborator Author

Christophe Bornet (cbornet) commented Apr 7, 2026

I think a more compelling change here would be switching from mypy to ty, FWIW

Happy to switch to ty too!
But much bigger work... :

  • all type ignores must be moved to ty error codes
  • doesn't support pydantic very well atm it seems...

if ignore_condition_name is None or not getattr(handler, ignore_condition_name):
event = getattr(handler, event_name)
if asyncio.iscoroutinefunction(event):
if inspect.iscoroutinefunction(event):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do we need inspect instead of asyncio for mypy version upgrade? otherwise, we are combining two different tasks into one PR, like upgrading mypy version, replacing asyncio with inspect

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes it’s needed by mypy upgrade. It comes from an update of typeshed in mypy.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sounds good then!!. Thnx for clarification

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it will be nice to document that inspect is preferred way rather than asyncio for newer version of python. I was looking for source why inspect.iscoroutinefunction is better than asyncio.iscoroutinefunction, but this is what I could find. other than if mypy states that explicit that u need to use inspect over asyncio

python/cpython#122858

Eitherway, I let u navigate this however u like

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Python 3.14 makes it clear at runtime that asyncio.iscoroutinefunction is deprecated

>>> import asyncio
>>> asyncio.iscoroutinefunction(int)
<python-input-1>:1: DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
False

The newest mypy just catched up to that.
I don't think it's needed to document that in LangChain itself. It would only be noise.

Copy link
Copy Markdown

@torontodeveloper Kevin K (torontodeveloper) left a comment

Choose a reason for hiding this comment

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

.
Also, this PR needs to be rebased/syncup with master branch as there are conflicts. Fyi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) external infra PRs made that include chores, devops, repo meta changes langchain `langchain` package issues & PRs size: XS < 50 LOC standard-tests Related to the package `standard-tests` text-splitters Related to the package `text-splitters` trusted-contributor >= 5 merged PRs in the `langchain-ai/langchain` repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants