Fixed for mypy 0.501.
The List and Dict types are no longer implicitly available. They must be imported from typing. Type annotations must appear before the doc comment in a function. Also fix type errors in these functions that weren't detected before.
This commit is contained in:
@@ -143,22 +143,22 @@ class Var(Expr):
|
||||
def is_input(self):
|
||||
# type: () -> bool
|
||||
"""Is this an input value to the src pattern?"""
|
||||
return not self.src_def and not self.dst_def
|
||||
return self.src_def is None and self.dst_def is None
|
||||
|
||||
def is_output(self):
|
||||
"""Is this an output value, defined in both src and dst patterns?"""
|
||||
# type: () -> bool
|
||||
return self.src_def and self.dst_def
|
||||
"""Is this an output value, defined in both src and dst patterns?"""
|
||||
return self.src_def is not None and self.dst_def is not None
|
||||
|
||||
def is_intermediate(self):
|
||||
"""Is this an intermediate value, defined only in the src pattern?"""
|
||||
# type: () -> bool
|
||||
return self.src_def and not self.dst_def
|
||||
"""Is this an intermediate value, defined only in the src pattern?"""
|
||||
return self.src_def is not None and self.dst_def is None
|
||||
|
||||
def is_temp(self):
|
||||
"""Is this a temp value, defined only in the dst pattern?"""
|
||||
# type: () -> bool
|
||||
return not self.src_def and self.dst_def
|
||||
"""Is this a temp value, defined only in the dst pattern?"""
|
||||
return self.src_def is None and self.dst_def is not None
|
||||
|
||||
def get_typevar(self):
|
||||
# type: () -> TypeVar
|
||||
|
||||
@@ -6,7 +6,7 @@ from .operands import Operand # noqa
|
||||
# The typing module is only required by mypy, and we don't use these imports
|
||||
# outside type comments.
|
||||
try:
|
||||
from typing import Tuple, Union, Any, Sequence, Iterable # noqa
|
||||
from typing import Dict, List, Tuple, Union, Any, Sequence, Iterable # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from .operands import Operand
|
||||
from .formats import InstructionFormat
|
||||
|
||||
try:
|
||||
from typing import Union, Sequence
|
||||
from typing import Union, Sequence, List # noqa
|
||||
# List of operands for ins/outs:
|
||||
OpList = Union[Sequence[Operand], Operand]
|
||||
MaybeBoundInst = Union['Instruction', 'BoundInstruction']
|
||||
|
||||
@@ -6,7 +6,7 @@ from .registers import RegClass, Register
|
||||
# The typing module is only required by mypy, and we don't use these imports
|
||||
# outside type comments.
|
||||
try:
|
||||
from typing import Tuple, Union, Any, Iterable, Sequence, TYPE_CHECKING # noqa
|
||||
from typing import Tuple, Union, Any, Iterable, Sequence, List, Set, TYPE_CHECKING # noqa
|
||||
from .instructions import MaybeBoundInst, InstructionGroup, InstructionFormat # noqa
|
||||
from .predicates import Predicate, FieldPredicate # noqa
|
||||
from .settings import SettingGroup # noqa
|
||||
|
||||
@@ -26,7 +26,7 @@ from . import is_power_of_two, next_power_of_two
|
||||
|
||||
|
||||
try:
|
||||
from typing import Sequence, Tuple # noqa
|
||||
from typing import Sequence, Tuple, List, Dict # noqa
|
||||
from .isa import TargetISA # noqa
|
||||
# A tuple uniquely identifying a register class inside a register bank.
|
||||
# (count, width, start)
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
from __future__ import absolute_import
|
||||
import math
|
||||
|
||||
try:
|
||||
from typing import Dict, List # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
# ValueType instances (i8, i32, ...) are provided in the cretonne.types module.
|
||||
class ValueType(object):
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import absolute_import
|
||||
from .ast import Def, Var, Apply
|
||||
|
||||
try:
|
||||
from typing import Union, Iterator, Sequence, Iterable # noqa
|
||||
from typing import Union, Iterator, Sequence, Iterable, List, Dict # noqa
|
||||
from .ast import Expr # noqa
|
||||
DefApply = Union[Def, Apply]
|
||||
except ImportError:
|
||||
|
||||
Reference in New Issue
Block a user