Skip to content

Commit 48d1294

Browse files
h-joocopybara-github
authored andcommitted
Do not make it fail when args is empty. Rather return unresolvable in that case.
PiperOrigin-RevId: 763867054
1 parent 7a0e7b9 commit 48d1294

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pytype/overlays/fiddle_overlay.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ def new_slot(
167167
self, node, unused_cls, *args, **kwargs
168168
) -> tuple[Node, "cfg.Variable"]:
169169
"""Create a Config or Partial instance from args."""
170+
# pass
171+
if not args:
172+
return node, self.ctx.new_unsolvable(node)
170173

171174
underlying = args[0].data[0]
172175
self._check_init_args(node, underlying, args, kwargs)

pytype/tests/test_fiddle_overlay.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,19 @@ def f() -> fiddle.Config[Simple]:
665665
return fiddle.Config(Simple, 1)
666666
""")
667667

668+
def test_no_crash_on_empty_args(self):
669+
# pass
670+
with self.DepTree([("fiddle.pyi", _FIDDLE_PYI)]):
671+
self.Check("""
672+
from typing import cast, Any
673+
import fiddle
674+
675+
def foo(*args):
676+
return
677+
678+
fiddle.Config(foo, *[1, 2], 3)
679+
""")
680+
668681

669682
if __name__ == "__main__":
670683
test_base.main()

0 commit comments

Comments
 (0)