From ab278ed75ecd0d64d294988c5c0bc9f4fcf51438 Mon Sep 17 00:00:00 2001 From: mdemello Date: Wed, 13 Dec 2023 15:06:37 -0800 Subject: [PATCH] FIX: Only call match_fiddle_instance_against_bare_type if we have a fiddle instance. PiperOrigin-RevId: 590725000 --- pytype/matcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytype/matcher.py b/pytype/matcher.py index 95a61194e..3fac3a862 100644 --- a/pytype/matcher.py +++ b/pytype/matcher.py @@ -1181,7 +1181,8 @@ def _match_instance_against_type(self, left, other_type, subst, view): return self._match_fiddle_instance( left.cls, left, other_type, subst, view) elif (isinstance(other_type, abstract.PyTDClass) and - fiddle_overlay.is_fiddle_buildable_pytd(other_type.pytd_cls)): + fiddle_overlay.is_fiddle_buildable_pytd(other_type.pytd_cls) and + isinstance(left, fiddle_overlay.Buildable)): # Handle a plain `fiddle.Config` imported from a pyi file. return self._match_fiddle_instance_against_bare_type( left.cls, left, other_type, subst, view) @@ -1303,8 +1304,7 @@ def _match_fiddle_instance_against_bare_type( self, left, instance, other_type, subst, view ): """Match a fiddle instance against an unsubscripted buildable pytd type.""" - if not isinstance(instance, fiddle_overlay.Buildable): - return None + assert isinstance(instance, fiddle_overlay.Buildable) assert isinstance(other_type, abstract.PyTDClass) # This is a plain fiddle.Config we have imported from a pyi file and not # subscripted, so it is still a PyTDClass