Skip to content

Commit 4e1b656

Browse files
committed
Use fully qualified names for ambiguous class names resembling builtins.
1 parent 09676c9 commit 4e1b656

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mypy/messages.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import re
1414
import difflib
1515
from textwrap import dedent
16+
import builtins
1617

18+
import typing
1719
from typing import cast, List, Dict, Any, Sequence, Iterable, Tuple, Set, Optional, Union
1820
from typing_extensions import Final
1921

@@ -1717,9 +1719,15 @@ def find_type_overlaps(*types: Type) -> Set[str]:
17171719
with their fullname.
17181720
"""
17191721
d = {} # type: Dict[str, Set[str]]
1722+
builtin_types = set(dir(builtins))
1723+
typing_types = set(dir(typing))
17201724
for type in types:
17211725
for inst in collect_all_instances(type):
17221726
d.setdefault(inst.type.name, set()).add(inst.type.fullname)
1727+
if inst.type.name in builtin_types:
1728+
d[inst.type.name].add('builtins.{}'.format(inst.type.name))
1729+
if inst.type.name in typing_types:
1730+
d[inst.type.name].add('typing.{}'.format(inst.type.name))
17231731

17241732
overlaps = set() # type: Set[str]
17251733
for fullnames in d.values():

0 commit comments

Comments
 (0)