fixes based on mypy
This commit is contained in:
parent
3191866ce0
commit
7a4a96ff5f
@ -239,7 +239,7 @@ class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||||||
target_pat = flattened[target]
|
target_pat = flattened[target]
|
||||||
if target_pat is None:
|
if target_pat is None:
|
||||||
raise PatternError(f'Circular reference in {name} to {target}')
|
raise PatternError(f'Circular reference in {name} to {target}')
|
||||||
if target_pat.is_empty() # avoid some extra allocations
|
if target_pat.is_empty(): # avoid some extra allocations
|
||||||
continue
|
continue
|
||||||
|
|
||||||
p = ref.as_pattern(pattern=flattened[target])
|
p = ref.as_pattern(pattern=flattened[target])
|
||||||
@ -574,7 +574,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
|
|||||||
for old_name in temp:
|
for old_name in temp:
|
||||||
new_name = rename_map.get(old_name, old_name)
|
new_name = rename_map.get(old_name, old_name)
|
||||||
for ref in self[new_name].refs:
|
for ref in self[new_name].refs:
|
||||||
ref.target = rename_map.get(ref.target, ref.target)
|
ref.target = rename_map.get(cast(str, ref.target), ref.target)
|
||||||
|
|
||||||
return rename_map
|
return rename_map
|
||||||
|
|
||||||
@ -805,10 +805,10 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
|
|||||||
) -> Set[str]:
|
) -> Set[str]:
|
||||||
# TODO doc prune_empty
|
# TODO doc prune_empty
|
||||||
trimmed = set()
|
trimmed = set()
|
||||||
while empty := set(name for name, pat in lib.items() if pat.is_empty()):
|
while empty := set(name for name, pat in self.items() if pat.is_empty()):
|
||||||
for name in empty:
|
for name in empty:
|
||||||
del lib[name]
|
del self[name]
|
||||||
for pat in lib.values():
|
for pat in self.values():
|
||||||
pat.refs = [ref for ref in pat.refs if ref.target not in empty]
|
pat.refs = [ref for ref in pat.refs if ref.target not in empty]
|
||||||
|
|
||||||
trimmed |= empty
|
trimmed |= empty
|
||||||
@ -824,7 +824,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
|
|||||||
# TODO doc delete()
|
# TODO doc delete()
|
||||||
del self[key]
|
del self[key]
|
||||||
if delete_refs:
|
if delete_refs:
|
||||||
for pat in lib.values():
|
for pat in self.values():
|
||||||
pat.refs = [ref for ref in pat.refs if ref.target != key]
|
pat.refs = [ref for ref in pat.refs if ref.target != key]
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
|
|||||||
target_pat = flattened[target]
|
target_pat = flattened[target]
|
||||||
if target_pat is None:
|
if target_pat is None:
|
||||||
raise PatternError(f'Circular reference in {name} to {target}')
|
raise PatternError(f'Circular reference in {name} to {target}')
|
||||||
if target_pat.is_empty() # avoid some extra allocations
|
if target_pat.is_empty(): # avoid some extra allocations
|
||||||
continue
|
continue
|
||||||
|
|
||||||
p = ref.as_pattern(pattern=flattened[target])
|
p = ref.as_pattern(pattern=flattened[target])
|
||||||
|
Loading…
Reference in New Issue
Block a user