Skip to content

feat(langchain): add ruff rules TRY #32047

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

Merged
merged 2 commits into from
Jul 21, 2025

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Jul 15, 2025

See https://docs.astral.sh/ruff/rules/#tryceratops-try

  • TRY004 (replace by TypeError) in main code is escaped with noqa to not break backward compatibility. The rule is still interesting for new code.
  • TRY301 ignored at the moment. This one is quite hard to fix and I'm not sure it's very interesting to activate it.

Copy link

vercel bot commented Jul 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jul 21, 2025 5:39pm

Copy link

codspeed-hq bot commented Jul 15, 2025

CodSpeed WallTime Performance Report

Merging #32047 will not alter performance

Comparing cbornet:langchain-ruff-try (ac7a4a6) with master (8b8d90b)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

@@ -178,10 +178,10 @@ def parse(self, text: str) -> dict[str, Any]:
parsed = parse_and_check_json_markdown(text, expected_keys)
if not isinstance(parsed["destination"], str):
msg = "Expected 'destination' to be a string."
raise ValueError(msg)
raise TypeError(msg)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think here we can replace with TypeError without breaking compatibility since it's wrapped later in a OutputParserException

Copy link

codspeed-hq bot commented Jul 15, 2025

CodSpeed Instrumentation Performance Report

Merging #32047 will not alter performance

Comparing cbornet:langchain-ruff-try (ac7a4a6) with master (8b8d90b)

Summary

✅ 14 untouched benchmarks

@mdrxy mdrxy merged commit 6426144 into langchain-ai:master Jul 21, 2025
28 checks passed
@cbornet cbornet deleted the langchain-ruff-try branch July 21, 2025 19:57
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