Skip to content

Commit

Permalink
Fix crash if "_" is in builtins (python#11811)
Browse files Browse the repository at this point in the history
allows the definition of "_" as function in builtins (e.g via typeshed).

fixes python#9802
  • Loading branch information
StefanM-TT authored and tushar-deepsource committed Jan 20, 2022
1 parent f86759e commit 41b5854
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/semanal.py
Expand Up @@ -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
Expand Down

0 comments on commit 41b5854

Please sign in to comment.