Skip to content

Commit af0b24a

Browse files
elazarggvanrossum
authored andcommitted
Tighten types for parse.py and some more (#2208)
1 parent c8a9b52 commit af0b24a

File tree

7 files changed

+92
-101
lines changed

7 files changed

+92
-101
lines changed

mypy/build.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@
2222
from os.path import dirname, basename
2323

2424
from typing import (AbstractSet, Dict, Iterable, Iterator, List,
25-
NamedTuple, Optional, Set, Tuple, Union, Mapping)
25+
NamedTuple, Optional, Set, Tuple, Union)
2626

27-
from mypy.types import Type
28-
from mypy.nodes import (MypyFile, Node, Import, ImportFrom, ImportAll,
29-
SymbolTableNode, MODULE_REF)
27+
from mypy.nodes import (MypyFile, Import, ImportFrom, ImportAll)
3028
from mypy.semanal import FirstPass, SemanticAnalyzer, ThirdPass
3129
from mypy.checker import TypeChecker
3230
from mypy.indirection import TypeIndirectionVisitor
3331
from mypy.errors import Errors, CompileError, DecodeError, report_internal_error
34-
from mypy import fixup
3532
from mypy.report import Reports
36-
from mypy import defaults
3733
from mypy import moduleinfo
3834
from mypy import util
3935
from mypy.fixup import fixup_module_pass_one, fixup_module_pass_two

mypy/exprtotype.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
"""Translate an expression (Node) to a Type value."""
1+
"""Translate an Expression to a Type value."""
22

33
from mypy.nodes import (
4-
Node, NameExpr, MemberExpr, IndexExpr, TupleExpr, ListExpr, StrExpr, BytesExpr, EllipsisExpr
4+
Expression, NameExpr, MemberExpr, IndexExpr, TupleExpr,
5+
ListExpr, StrExpr, BytesExpr, EllipsisExpr
56
)
67
from mypy.parsetype import parse_str_as_type, TypeParseError
78
from mypy.types import Type, UnboundType, TypeList, EllipsisType
@@ -11,7 +12,7 @@ class TypeTranslationError(Exception):
1112
"""Exception raised when an expression is not valid as a type."""
1213

1314

14-
def expr_to_unanalyzed_type(expr: Node) -> Type:
15+
def expr_to_unanalyzed_type(expr: Expression) -> Type:
1516
"""Translate an expression to the corresponding type.
1617
1718
The result is not semantically analyzed. It can be UnboundType or TypeList.

mypy/nodes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,12 +1762,12 @@ def accept(self, visitor: NodeVisitor[T]) -> T:
17621762
return visitor.visit_newtype_expr(self)
17631763

17641764

1765-
class AwaitExpr(Node):
1765+
class AwaitExpr(Expression):
17661766
"""Await expression (await ...)."""
17671767

1768-
expr = None # type: Node
1768+
expr = None # type: Expression
17691769

1770-
def __init__(self, expr: Node) -> None:
1770+
def __init__(self, expr: Expression) -> None:
17711771
self.expr = expr
17721772

17731773
def accept(self, visitor: NodeVisitor[T]) -> T:

0 commit comments

Comments
 (0)