From a94dc073fd582cf0a78a6c3e616222fdce11572a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 May 2021 11:42:24 -0700 Subject: [PATCH] Remove assertion from TypeGuard serialization This came up in python/typeshed#5473: mypy started crashing when I made a function return TypeGuard[Type[Any]]. I wasn't able to reproduce this locally so far, but verified that removing the assertion fixes the crash. --- mypy/types.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mypy/types.py b/mypy/types.py index bf138f343b5a..4587dadfd885 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -1271,8 +1271,6 @@ def __eq__(self, other: object) -> bool: def serialize(self) -> JsonDict: # TODO: As an optimization, leave out everything related to # generic functions for non-generic functions. - assert (self.type_guard is None - or isinstance(get_proper_type(self.type_guard), Instance)), str(self.type_guard) return {'.class': 'CallableType', 'arg_types': [t.serialize() for t in self.arg_types], 'arg_kinds': self.arg_kinds,