Fix some mypy errors.
It looks like mypy 0.560 doesn't like when a local variable changes its type inside a function. Fixes introduce a new variable instead of reusing an existing one.
This commit is contained in:
@@ -290,12 +290,12 @@ class Instruction(object):
|
|||||||
# Allow a single Operand instance instead of the awkward singleton
|
# Allow a single Operand instance instead of the awkward singleton
|
||||||
# tuple syntax.
|
# tuple syntax.
|
||||||
if isinstance(x, Operand):
|
if isinstance(x, Operand):
|
||||||
x = (x,)
|
y = (x,) # type: Tuple[Operand, ...]
|
||||||
else:
|
else:
|
||||||
x = tuple(x)
|
y = tuple(x)
|
||||||
for op in x:
|
for op in y:
|
||||||
assert isinstance(op, Operand)
|
assert isinstance(op, Operand)
|
||||||
return x
|
return y
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _to_constraint_tuple(x):
|
def _to_constraint_tuple(x):
|
||||||
@@ -307,12 +307,12 @@ class Instruction(object):
|
|||||||
# import placed here to avoid circular dependency
|
# import placed here to avoid circular dependency
|
||||||
from .ti import TypeConstraint # noqa
|
from .ti import TypeConstraint # noqa
|
||||||
if isinstance(x, TypeConstraint):
|
if isinstance(x, TypeConstraint):
|
||||||
x = (x,)
|
y = (x,) # type: Tuple[TypeConstraint, ...]
|
||||||
else:
|
else:
|
||||||
x = tuple(x)
|
y = tuple(x)
|
||||||
for op in x:
|
for op in y:
|
||||||
assert isinstance(op, TypeConstraint)
|
assert isinstance(op, TypeConstraint)
|
||||||
return x
|
return y
|
||||||
|
|
||||||
def bind(self, *args):
|
def bind(self, *args):
|
||||||
# type: (*ValueType) -> BoundInstruction
|
# type: (*ValueType) -> BoundInstruction
|
||||||
|
|||||||
@@ -62,16 +62,19 @@ class UniqueSeqTable:
|
|||||||
"""
|
"""
|
||||||
if len(seq) == 0:
|
if len(seq) == 0:
|
||||||
return 0
|
return 0
|
||||||
seq = tuple(seq)
|
tseq = tuple(seq)
|
||||||
if seq in self.index:
|
if tseq in self.index:
|
||||||
return self.index[seq]
|
return self.index[tseq]
|
||||||
|
|
||||||
idx = len(self.table)
|
idx = len(self.table)
|
||||||
self.table.extend(seq)
|
self.table.extend(tseq)
|
||||||
|
|
||||||
# Add seq and all sub-sequences to `index`.
|
# Add seq and all sub-sequences to `index`.
|
||||||
for length in range(1, len(seq) + 1):
|
index = self.index # type: Dict[Tuple[Any, ...], int]
|
||||||
for offset in range(len(seq) - length + 1):
|
assert index is not None
|
||||||
self.index[seq[offset:offset+length]] = idx + offset
|
for length in range(1, len(tseq) + 1):
|
||||||
|
for offset in range(len(tseq) - length + 1):
|
||||||
|
key = tseq[offset:offset+length]
|
||||||
|
index[key] = idx + offset
|
||||||
|
|
||||||
return idx
|
return idx
|
||||||
|
|||||||
Reference in New Issue
Block a user