Skip to content

Do not import List, Dict, and Set by default #2863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def make_argument(arg: ast3.arg, default: Optional[ast3.expr], kind: int) -> Arg
if arg.annotation is not None:
arg_type = TypeConverter(self.errors, line=line).visit(arg.annotation)
elif arg.type_comment is not None:
arg_type = parse_type_comment(arg.type_comment, arg.lineno, arg.col_offset)
arg_type = parse_type_comment(arg.type_comment, arg.lineno, self.errors)
return Argument(Var(arg.arg), arg_type, self.visit(default), kind)

new_args = []
Expand Down
2 changes: 1 addition & 1 deletion mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pprint
import sys

from typing import Any, Mapping, Optional, Tuple, List, Pattern
from typing import Any, Mapping, Optional, Tuple, List, Pattern, Dict

from mypy import defaults

Expand Down
2 changes: 2 additions & 0 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ def visit_file(self, file_node: MypyFile, fnam: str, options: Options) -> None:

if self.cur_mod_id == 'builtins':
remove_imported_names_from_symtable(self.globals, 'builtins')
for alias_name in ['List', 'Dict', 'Set']:
self.globals.pop(alias_name, None)

if '__all__' in self.globals:
for name, g in self.globals.items():
Expand Down
2 changes: 1 addition & 1 deletion mypy/test/testgraph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test cases for graph processing code in build.py."""

from typing import AbstractSet, Dict, Set
from typing import AbstractSet, Dict, Set, List

from mypy.myunit import Suite, assert_equal
from mypy.build import BuildManager, State, BuildSourceSet
Expand Down
2 changes: 1 addition & 1 deletion mypy/typevars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Union, List

from mypy.nodes import TypeInfo

Expand Down
2 changes: 1 addition & 1 deletion test-data/samples/crawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys
import time
import urllib.parse
from typing import Any, Generator, IO, Optional, Sequence, Set, Tuple
from typing import Any, Generator, IO, Optional, Sequence, Set, Tuple, List, Dict


ARGS = argparse.ArgumentParser(description="Web crawler")
Expand Down
2 changes: 1 addition & 1 deletion test-data/samples/crawl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
import time
import urllib.parse
from typing import Any, Awaitable, IO, Optional, Sequence, Set, Tuple
from typing import Any, Awaitable, IO, Optional, Sequence, Set, Tuple, List, Dict


ARGS = argparse.ArgumentParser(description="Web crawler")
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ print(b.x + 1)
4

[case testInferenceWithLambda]
from typing import TypeVar, Iterable, Iterator
from typing import TypeVar, Iterable, Iterator, List
import itertools

_T = TypeVar('_T')
Expand Down