From f848955ecc8a80f22c047d563695f63c9b0897f5 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 16:54:05 +0200 Subject: [PATCH 1/9] Remove unused imports in checkexpr module --- mypy/checkexpr.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 0ba58694792e..d81c57868951 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -4,7 +4,7 @@ from contextlib import contextmanager from typing import ( cast, Dict, Set, List, Tuple, Callable, Union, Optional, Iterable, - Sequence, Any, Iterator + Sequence, Iterator ) MYPY = False if MYPY: @@ -18,9 +18,8 @@ from mypy.types import ( Type, AnyType, CallableType, Overloaded, NoneTyp, TypeVarDef, TupleType, TypedDictType, Instance, TypeVarType, ErasedType, UnionType, - PartialType, DeletedType, UnboundType, UninhabitedType, TypeType, TypeOfAny, - true_only, false_only, is_named_instance, function_type, callable_type, FunctionLike, - get_typ_args, StarType + PartialType, DeletedType, UninhabitedType, TypeType, TypeOfAny, true_only, + false_only, is_named_instance, function_type, callable_type, FunctionLike, StarType ) from mypy.nodes import ( NameExpr, RefExpr, Var, FuncDef, OverloadedFuncDef, TypeInfo, CallExpr, @@ -45,13 +44,12 @@ from mypy.infer import infer_type_arguments, infer_function_type_arguments from mypy import join from mypy.meet import narrow_declared_type -from mypy.maptype import map_instance_to_supertype from mypy.subtypes import ( is_subtype, is_proper_subtype, is_equivalent, find_member, non_method_protocol_members, ) from mypy import applytype from mypy import erasetype -from mypy.checkmember import analyze_member_access, type_object_type, bind_self +from mypy.checkmember import analyze_member_access, type_object_type from mypy.constraints import get_actual_type from mypy.checkstrformat import StringFormatterChecker from mypy.expandtype import expand_type, expand_type_by_instance, freshen_function_type_vars @@ -61,8 +59,6 @@ from mypy.plugin import Plugin, MethodContext, MethodSigContext, FunctionContext from mypy.typeanal import make_optional_type -from mypy import experiments - # Type of callback user for checking individual function arguments. See # check_args() below for details. ArgChecker = Callable[[Type, Type, int, Type, int, int, CallableType, Context, MessageBuilder], From 44ac4b679fb41c10cc45ad31dcc36cb994271038 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 17:04:03 +0200 Subject: [PATCH 2/9] Remove unused import in fastparse2 module --- mypy/fastparse2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mypy/fastparse2.py b/mypy/fastparse2.py index 713b8f2ff4b3..970d1f0ce000 100644 --- a/mypy/fastparse2.py +++ b/mypy/fastparse2.py @@ -14,7 +14,6 @@ different class hierarchies, which made it difficult to write a shared visitor between the two in a typesafe way. """ -from functools import wraps import sys from typing import Tuple, Union, TypeVar, Callable, Sequence, Optional, Any, Dict, cast, List From c4702bd6145a341ae82d0d30ab33a4646aa141df Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 17:11:06 +0200 Subject: [PATCH 3/9] Remove unused import in util module --- mypy/util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mypy/util.py b/mypy/util.py index bcf5d9edee99..3400cbdcfddd 100644 --- a/mypy/util.py +++ b/mypy/util.py @@ -1,6 +1,5 @@ """Utility functions with no non-trivial dependencies.""" import inspect -import genericpath # type: ignore # no stub files yet import os import pathlib import re From debbed8860c09e6aedb6af1b6ae836682022d8c6 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 17:21:54 +0200 Subject: [PATCH 4/9] Remove unused imports in main module --- mypy/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 1c47affeae4e..588ea2a7cb57 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -9,13 +9,12 @@ import sys import time -from typing import Any, Dict, List, Mapping, Optional, Tuple, Callable +from typing import Any, Dict, List, Mapping, Optional, Tuple from mypy import build from mypy import defaults from mypy import experiments from mypy import util -from mypy.build import BuildResult from mypy.modulefinder import BuildSource, FindModuleCache, mypy_path, SearchPaths from mypy.find_sources import create_source_list, InvalidSourceList from mypy.fscache import FileSystemCache From 9f4d94bc4fc802f996880b0ebfe2853dfaf20560 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 17:24:31 +0200 Subject: [PATCH 5/9] Remove unused imports in errors module --- mypy/errors.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/errors.py b/mypy/errors.py index f8893290e32b..19028e12ab56 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -2,9 +2,8 @@ import sys import traceback from collections import OrderedDict, defaultdict -from contextlib import contextmanager -from typing import Tuple, List, TypeVar, Set, Dict, Iterator, Optional, cast +from typing import Tuple, List, TypeVar, Set, Dict, Optional from mypy.scope import Scope from mypy.options import Options From 893edc606ca46eb91aa94ed9ce70d2473ace02f2 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 17:38:42 +0200 Subject: [PATCH 6/9] Harmonize typing import statements in stats module --- mypy/stats.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mypy/stats.py b/mypy/stats.py index 3c00d9440a68..4f05ac983916 100644 --- a/mypy/stats.py +++ b/mypy/stats.py @@ -1,10 +1,9 @@ """Utilities for calculating and reporting statistics about types.""" import os.path -import typing from collections import Counter -from typing import Dict, List, cast, Optional +from typing import cast, Counter, Dict, List, Optional from mypy.traverser import TraverserVisitor from mypy.typeanal import collect_all_inner_types @@ -67,7 +66,7 @@ def __init__(self, self.line_map = {} # type: Dict[int, int] - self.type_of_any_counter = Counter() # type: typing.Counter[int] + self.type_of_any_counter = Counter() # type: Counter[int] self.any_line_map = {} # type: Dict[int, List[AnyType]] self.output = [] # type: List[str] From e7834ed6e8bd72fd7066195ec9326280340f81fb Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 17:40:40 +0200 Subject: [PATCH 7/9] Remove unused import in dumpmodule script --- scripts/dumpmodule.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/dumpmodule.py b/scripts/dumpmodule.py index 5d31241f4a0d..ac8470ece763 100644 --- a/scripts/dumpmodule.py +++ b/scripts/dumpmodule.py @@ -12,7 +12,6 @@ import sys import types from typing import Text -from collections import defaultdict if sys.version_info >= (3, 0): From d97ea7e770674375748f3b2e89780dd9382f3906 Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 18:39:07 +0200 Subject: [PATCH 8/9] Import os instead of os.path --- mypy/stats.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mypy/stats.py b/mypy/stats.py index 4f05ac983916..888ab5eebf4e 100644 --- a/mypy/stats.py +++ b/mypy/stats.py @@ -1,9 +1,10 @@ """Utilities for calculating and reporting statistics about types.""" -import os.path +import os +import typing from collections import Counter -from typing import cast, Counter, Dict, List, Optional +from typing import Dict, List, cast, Optional from mypy.traverser import TraverserVisitor from mypy.typeanal import collect_all_inner_types @@ -66,7 +67,7 @@ def __init__(self, self.line_map = {} # type: Dict[int, int] - self.type_of_any_counter = Counter() # type: Counter[int] + self.type_of_any_counter = Counter() # type: typing.Counter[int] self.any_line_map = {} # type: Dict[int, List[AnyType]] self.output = [] # type: List[str] From ea182ad680f266134d358a16a5734204bd2dca7c Mon Sep 17 00:00:00 2001 From: Emil Hessman Date: Sat, 29 Sep 2018 18:40:57 +0200 Subject: [PATCH 9/9] Add trailing , to import statements --- mypy/checkexpr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index d81c57868951..0ed9e4948d3d 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -19,7 +19,7 @@ Type, AnyType, CallableType, Overloaded, NoneTyp, TypeVarDef, TupleType, TypedDictType, Instance, TypeVarType, ErasedType, UnionType, PartialType, DeletedType, UninhabitedType, TypeType, TypeOfAny, true_only, - false_only, is_named_instance, function_type, callable_type, FunctionLike, StarType + false_only, is_named_instance, function_type, callable_type, FunctionLike, StarType, ) from mypy.nodes import ( NameExpr, RefExpr, Var, FuncDef, OverloadedFuncDef, TypeInfo, CallExpr,