diff --git a/masque/builder/renderpather.py b/masque/builder/renderpather.py index 11759a5..8dae18b 100644 --- a/masque/builder/renderpather.py +++ b/masque/builder/renderpather.py @@ -248,7 +248,7 @@ class RenderPather(PortList): other_tgt = self.library[other.name] # get rid of plugged ports - for kk in map_in.keys(): + for kk in map_in: if kk in self.paths: self.paths[kk].append(RenderStep('P', None, self.ports[kk].copy(), self.ports[kk].copy(), None)) diff --git a/masque/library.py b/masque/library.py index d5b3136..ce5adb2 100644 --- a/masque/library.py +++ b/masque/library.py @@ -176,7 +176,7 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta): tops = tuple(self.keys()) if skip is None: - skip = set([None]) + skip = {None} if isinstance(tops, str): tops = (tops,) @@ -213,7 +213,7 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta): if isinstance(tops, str): tops = (tops,) - keep = cast(set[str], self.referenced_patterns(tops) - set((None,))) + keep = cast(set[str], self.referenced_patterns(tops) - {None}) keep |= set(tops) filtered = {kk: vv for kk, vv in self.items() if kk in keep} @@ -665,7 +665,7 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta): duplicates = set(self.keys()) & set(other.keys()) if not duplicates: - for key in other.keys(): + for key in other: self._merge(key, other, key) return {} @@ -912,7 +912,7 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta): if isinstance(tops, str): tops = (tops,) - keep = cast(set[str], self.referenced_patterns(tops) - set((None,))) + keep = cast(set[str], self.referenced_patterns(tops) - {None}) keep |= set(tops) new = type(self)() @@ -934,7 +934,7 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta): A set containing the names of all deleted patterns """ trimmed = set() - while empty := set(name for name, pat in self.items() if pat.is_empty()): + while empty := {name for name, pat in self.items() if pat.is_empty()}: for name in empty: del self[name] diff --git a/masque/pattern.py b/masque/pattern.py index 0c3b6cb..74e5e0f 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -472,10 +472,10 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): self.polygonize() for layer in self.shapes: - self.shapes[layer] = list(chain.from_iterable(( + self.shapes[layer] = list(chain.from_iterable( ss.manhattanize(grid_x, grid_y) for ss in self.shapes[layer] - ))) + )) return self def as_polygons(self, library: Mapping[str, 'Pattern']) -> list[NDArray[numpy.float64]]: diff --git a/masque/ports.py b/masque/ports.py index 8f6a817..6f029b1 100644 --- a/masque/ports.py +++ b/masque/ports.py @@ -239,7 +239,7 @@ class PortList(metaclass=ABCMeta): if duplicates: raise PortError(f'Unrenamed ports would be overwritten: {duplicates}') - renamed = {mapping[k]: self.ports.pop(k) for k in mapping.keys()} + renamed = {vv: self.ports.pop(kk) for kk, vv in mapping.items()} if None in renamed: del renamed[None] diff --git a/masque/utils/autoslots.py b/masque/utils/autoslots.py index 4b1d001..8b60897 100644 --- a/masque/utils/autoslots.py +++ b/masque/utils/autoslots.py @@ -17,11 +17,11 @@ class AutoSlots(ABCMeta): for base in bases: parents |= set(base.mro()) - slots = tuple(dctn.get('__slots__', tuple())) + slots = tuple(dctn.get('__slots__', ())) for parent in parents: if not hasattr(parent, '__annotations__'): continue - slots += tuple(getattr(parent, '__annotations__').keys()) + slots += tuple(parent.__annotations__.keys()) dctn['__slots__'] = slots return super().__new__(cls, name, bases, dctn) diff --git a/masque/utils/ports2data.py b/masque/utils/ports2data.py index 1092b7a..b67fa0a 100644 --- a/masque/utils/ports2data.py +++ b/masque/utils/ports2data.py @@ -150,7 +150,7 @@ def data_to_ports_flat( Returns: The updated `pattern`. Port labels are not removed. """ - labels = list(chain.from_iterable((pattern.labels[layer] for layer in layers))) + labels = list(chain.from_iterable(pattern.labels[layer] for layer in layers)) if not labels: return pattern