Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion stubs/braintree/braintree/search.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from typing import overload

class Search:
class IsNodeBuilder:
Expand Down Expand Up @@ -41,7 +42,12 @@ class Search:
name: Incomplete
whitelist: Incomplete
def __init__(self, name, whitelist=[]) -> None: ...
def in_list(self, *values): ...

@overload
def in_list(self, value: list[str]) -> Search.Node: ...
@overload
def in_list(self, *values: str) -> Search.Node: ...

@donbarbos donbarbos Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since a list can be used as such a sequence of values for the first argument, I think it might be worth adding an overload for this case.
(Please, import Unused from _typeshed)

Suggested change
def in_list(self, *values: str) -> Search.Node: ...
@overload
def in_list(self, value: list[str], *values: Unused) -> Search.Node: ...
@overload
def in_list(self, *values: str) -> Search.Node: ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@donbarbos oops, missed that. Thanks!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not familiar with braintree, but I assume calling in_list if a list as first argument and further arguments would indicate a bug or misunderstanding of the API. In this case I think it's safer to remove the *values argument from the first overload.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, if the first argument is a list, it uses it and ignores the rest:

        def in_list(self, *values):
            if isinstance(values[0], list):
                values = values[0]

Passing a list and anything following it would not throw an error, but also would not make any sense. I removed the *values: Unused bit from the PR.


def __eq__(self, value): ...

class MultipleValueOrTextNodeBuilder(TextNodeBuilder, MultipleValueNodeBuilder):
Expand Down