Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pytype/abstract/_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def call(
self.func.__self__ # pytype: disable=attribute-error
)
args = args.simplify(node, self.ctx, match_signature=sig)
del sig
posargs = [u.AssignToNewVariable(node) for u in args.posargs]
namedargs = {
k: u.AssignToNewVariable(node) for k, u in args.namedargs.items()
Expand Down
15 changes: 15 additions & 0 deletions pytype/overlays/functools_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ def call(
) -> tuple[cfg.CFGNode, cfg.Variable]:
# ``NativeFunction.call`` does not forward *args and **kwargs to the
# underlying function, so we do it here to avoid changing core pytype APIs.
#
# The simplification below ensures that the *args/**kwargs cannot in fact
# be split into individual arguments. This logic follow the implementation
# in the base class.
sig = None
if isinstance(
self.func.__self__, # pytype: disable=attribute-error
abstract.CallableClass,
):
sig = function.Signature.from_callable(
self.func.__self__ # pytype: disable=attribute-error
)
args = args.simplify(node, self.ctx, match_signature=sig)
del sig

starargs = args.starargs
starstarargs = args.starstarargs
if starargs is not None:
Expand Down
11 changes: 11 additions & 0 deletions pytype/tests/test_functions1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,17 @@ def f(a, b=None):
partial_f(0)
""")

def test_functools_partial_with_starstar(self):
self.Check("""
import functools
def f(a: str, b: int, c: list):
pass
partial_f = functools.partial(f, "foo")

def test(**kwargs):
partial_f(42, **kwargs)
""")

def test_functools_partial_overloaded(self):
self.Check("""
import functools
Expand Down
Loading