From 41b5854c272834580820a7c813805b81af2f4f7a Mon Sep 17 00:00:00 2001 From: StefanM-TT <96481686+StefanM-TT@users.noreply.github.com> Date: Wed, 22 Dec 2021 00:30:12 +0100 Subject: [PATCH] Fix crash if "_" is in builtins (#11811) allows the definition of "_" as function in builtins (e.g via typeshed). fixes #9802 --- mypy/semanal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/semanal.py b/mypy/semanal.py index f29965f6ff8f..a9226d2cdd0c 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -4296,7 +4296,7 @@ def lookup(self, name: str, ctx: Context, assert isinstance(b.node, MypyFile) table = b.node.names if name in table: - if name[0] == "_" and name[1] != "_": + if len(name) > 1 and name[0] == "_" and name[1] != "_": if not suppress_errors: self.name_not_defined(name, ctx) return None