Skip to content
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

core: Add ruff rules A (builtins shadowing) #29312

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Jan 20, 2025

See https://docs.astral.sh/ruff/rules/#flake8-builtins-a

  • Renamed vars where possible
  • Added noqa where backward compatibility was needed
  • Added @override when applicable

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jan 20, 2025
Copy link

vercel bot commented Jan 20, 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 Mar 27, 2025 11:01am

@dosubot dosubot bot added Ɑ: core Related to langchain-core 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs labels Jan 20, 2025
from langchain_core.messages import BaseMessage
from langchain_core.output_parsers.transform import BaseTransformOutputParser

T = TypeVar("T")


def droplastn(iter: Iterator[T], n: int) -> Iterator[T]:
def _droplastn(iterator: Iterator[T], n: int) -> Iterator[T]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it OK to consider droplastn private ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I generally suggest avoiding doing so unless there's a good reason -- we didn't have an official policy about the public interface, so it's hard to know what user code might be relying on, and unclear that there's a good reason to risk breaking some users code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. I understand.
As a user though, I would really not use a function from output_parsers.list in my own code...

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 rolled back. PTAL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @eyurtsev could you take another look ?

@cbornet cbornet force-pushed the ruff-core-a branch 5 times, most recently from ed51615 to 298117c Compare January 25, 2025 17:30
@cbornet cbornet requested a review from eyurtsev February 27, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: core Related to langchain-core 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
Status: Internal
Development

Successfully merging this pull request may close these issues.

2 participants