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
|
||||
# tuple syntax.
|
||||
if isinstance(x, Operand):
|
||||
x = (x,)
|
||||
y = (x,) # type: Tuple[Operand, ...]
|
||||
else:
|
||||
x = tuple(x)
|
||||
for op in x:
|
||||
y = tuple(x)
|
||||
for op in y:
|
||||
assert isinstance(op, Operand)
|
||||
return x
|
||||
return y
|
||||
|
||||
@staticmethod
|
||||
def _to_constraint_tuple(x):
|
||||
@@ -307,12 +307,12 @@ class Instruction(object):
|
||||
# import placed here to avoid circular dependency
|
||||
from .ti import TypeConstraint # noqa
|
||||
if isinstance(x, TypeConstraint):
|
||||
x = (x,)
|
||||
y = (x,) # type: Tuple[TypeConstraint, ...]
|
||||
else:
|
||||
x = tuple(x)
|
||||
for op in x:
|
||||
y = tuple(x)
|
||||
for op in y:
|
||||
assert isinstance(op, TypeConstraint)
|
||||
return x
|
||||
return y
|
||||
|
||||
def bind(self, *args):
|
||||
# type: (*ValueType) -> BoundInstruction
|
||||
|
||||
@@ -62,16 +62,19 @@ class UniqueSeqTable:
|
||||
"""
|
||||
if len(seq) == 0:
|
||||
return 0
|
||||
seq = tuple(seq)
|
||||
if seq in self.index:
|
||||
return self.index[seq]
|
||||
tseq = tuple(seq)
|
||||
if tseq in self.index:
|
||||
return self.index[tseq]
|
||||
|
||||
idx = len(self.table)
|
||||
self.table.extend(seq)
|
||||
self.table.extend(tseq)
|
||||
|
||||
# Add seq and all sub-sequences to `index`.
|
||||
for length in range(1, len(seq) + 1):
|
||||
for offset in range(len(seq) - length + 1):
|
||||
self.index[seq[offset:offset+length]] = idx + offset
|
||||
index = self.index # type: Dict[Tuple[Any, ...], int]
|
||||
assert index is not None
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user