Skip to content

Commit 9aef23b

Browse files
authored
Do not import FrozenSet by default (#3181)
1 parent db96af3 commit 9aef23b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mypy/semanal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ def visit_file(self, file_node: MypyFile, fnam: str, options: Options) -> None:
265265

266266
if self.cur_mod_id == 'builtins':
267267
remove_imported_names_from_symtable(self.globals, 'builtins')
268-
for alias_name in ['List', 'Dict', 'Set']:
269-
self.globals.pop(alias_name, None)
268+
for alias_name in type_aliases:
269+
self.globals.pop(alias_name.split('.')[-1], None)
270270

271271
if '__all__' in self.globals:
272272
for name, g in self.globals.items():

test-data/unit/pythoneval.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,10 @@ print('>', list(b))
747747
[case testInternalBuiltinDefinition]
748748
import typing
749749
def f(x: _T) -> None: pass
750+
s: FrozenSet
750751
[out]
751752
_program.py:2: error: Name '_T' is not defined
753+
_program.py:3: error: Name 'FrozenSet' is not defined
752754

753755
[case testVarArgsFunctionSubtyping]
754756
import typing

0 commit comments

Comments
 (0)