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):
|
def is_input(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
"""Is this an input value to the src pattern?"""
|
"""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):
|
def is_output(self):
|
||||||
"""Is this an output value, defined in both src and dst patterns?"""
|
|
||||||
# type: () -> bool
|
# 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):
|
def is_intermediate(self):
|
||||||
"""Is this an intermediate value, defined only in the src pattern?"""
|
|
||||||
# type: () -> bool
|
# 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):
|
def is_temp(self):
|
||||||
"""Is this a temp value, defined only in the dst pattern?"""
|
|
||||||
# type: () -> bool
|
# 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):
|
def get_typevar(self):
|
||||||
# type: () -> TypeVar
|
# 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
|
# The typing module is only required by mypy, and we don't use these imports
|
||||||
# outside type comments.
|
# outside type comments.
|
||||||
try:
|
try:
|
||||||
from typing import Tuple, Union, Any, Sequence, Iterable # noqa
|
from typing import Dict, List, Tuple, Union, Any, Sequence, Iterable # noqa
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from .operands import Operand
|
|||||||
from .formats import InstructionFormat
|
from .formats import InstructionFormat
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Union, Sequence
|
from typing import Union, Sequence, List # noqa
|
||||||
# List of operands for ins/outs:
|
# List of operands for ins/outs:
|
||||||
OpList = Union[Sequence[Operand], Operand]
|
OpList = Union[Sequence[Operand], Operand]
|
||||||
MaybeBoundInst = Union['Instruction', 'BoundInstruction']
|
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
|
# The typing module is only required by mypy, and we don't use these imports
|
||||||
# outside type comments.
|
# outside type comments.
|
||||||
try:
|
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 .instructions import MaybeBoundInst, InstructionGroup, InstructionFormat # noqa
|
||||||
from .predicates import Predicate, FieldPredicate # noqa
|
from .predicates import Predicate, FieldPredicate # noqa
|
||||||
from .settings import SettingGroup # noqa
|
from .settings import SettingGroup # noqa
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from . import is_power_of_two, next_power_of_two
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Sequence, Tuple # noqa
|
from typing import Sequence, Tuple, List, Dict # noqa
|
||||||
from .isa import TargetISA # noqa
|
from .isa import TargetISA # noqa
|
||||||
# A tuple uniquely identifying a register class inside a register bank.
|
# A tuple uniquely identifying a register class inside a register bank.
|
||||||
# (count, width, start)
|
# (count, width, start)
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
try:
|
||||||
|
from typing import Dict, List # noqa
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# ValueType instances (i8, i32, ...) are provided in the cretonne.types module.
|
# ValueType instances (i8, i32, ...) are provided in the cretonne.types module.
|
||||||
class ValueType(object):
|
class ValueType(object):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from __future__ import absolute_import
|
|||||||
from .ast import Def, Var, Apply
|
from .ast import Def, Var, Apply
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Union, Iterator, Sequence, Iterable # noqa
|
from typing import Union, Iterator, Sequence, Iterable, List, Dict # noqa
|
||||||
from .ast import Expr # noqa
|
from .ast import Expr # noqa
|
||||||
DefApply = Union[Def, Apply]
|
DefApply = Union[Def, Apply]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ from cdsl.instructions import Instruction # noqa
|
|||||||
from cdsl.operands import Operand # noqa
|
from cdsl.operands import Operand # noqa
|
||||||
from cdsl.typevar import TypeVar # noqa
|
from cdsl.typevar import TypeVar # noqa
|
||||||
|
|
||||||
|
# The typing module is only required by mypy, and we don't use these imports
|
||||||
|
# outside type comments.
|
||||||
|
try:
|
||||||
|
from typing import List # noqa
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def gen_formats(fmt):
|
def gen_formats(fmt):
|
||||||
# type: (srcgen.Formatter) -> None
|
# type: (srcgen.Formatter) -> None
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from __future__ import absolute_import
|
|||||||
import srcgen
|
import srcgen
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Sequence # noqa
|
from typing import Sequence, List # noqa
|
||||||
from cdsl.isa import TargetISA # noqa
|
from cdsl.isa import TargetISA # noqa
|
||||||
from cdsl.registers import RegBank, RegClass # noqa
|
from cdsl.registers import RegBank, RegClass # noqa
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ from __future__ import absolute_import
|
|||||||
from cdsl.isa import TargetISA # noqa
|
from cdsl.isa import TargetISA # noqa
|
||||||
from . import riscv, intel, arm32, arm64
|
from . import riscv, intel, arm32, arm64
|
||||||
|
|
||||||
|
try:
|
||||||
|
from typing import List # noqa
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def all_isas():
|
def all_isas():
|
||||||
# type: () -> List[TargetISA]
|
# type: () -> List[TargetISA]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Any # noqa
|
from typing import Any, List # noqa
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user