From 6ec94fb3c37c9c8e9126a6588d00013dcb2c8a08 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 28 Jul 2024 19:33:16 -0700 Subject: [PATCH] import Sequence et al from collections.abc not typing --- examples/tutorial/basic_shapes.py | 2 +- examples/tutorial/devices.py | 2 +- examples/tutorial/library.py | 3 ++- examples/tutorial/pather.py | 2 +- examples/tutorial/pcgen.py | 2 +- examples/tutorial/renderpather.py | 2 +- masque/builder/builder.py | 3 ++- masque/builder/pather.py | 3 ++- masque/builder/renderpather.py | 3 ++- masque/builder/tools.py | 3 ++- masque/builder/utils.py | 3 ++- masque/file/dxf.py | 3 ++- masque/file/gdsii.py | 3 ++- masque/file/oasis.py | 3 ++- masque/file/svg.py | 2 +- masque/file/utils.py | 3 ++- masque/library.py | 2 +- masque/pattern.py | 3 ++- masque/ports.py | 3 ++- masque/ref.py | 3 ++- masque/shapes/path.py | 3 ++- masque/shapes/polygon.py | 3 ++- masque/shapes/shape.py | 3 ++- masque/utils/decorators.py | 2 +- masque/utils/deferreddict.py | 3 ++- masque/utils/pack2d.py | 2 +- masque/utils/ports2data.py | 2 +- masque/utils/transform.py | 2 +- 28 files changed, 45 insertions(+), 28 deletions(-) diff --git a/examples/tutorial/basic_shapes.py b/examples/tutorial/basic_shapes.py index f8e1eef..87baaf0 100644 --- a/examples/tutorial/basic_shapes.py +++ b/examples/tutorial/basic_shapes.py @@ -1,4 +1,4 @@ -from typing import Sequence +from collections.abc import Sequence import numpy from numpy import pi diff --git a/examples/tutorial/devices.py b/examples/tutorial/devices.py index 9556ee3..6b9cfa2 100644 --- a/examples/tutorial/devices.py +++ b/examples/tutorial/devices.py @@ -1,4 +1,4 @@ -from typing import Sequence, Mapping +from collections.abc import Sequence, Mapping import numpy from numpy import pi diff --git a/examples/tutorial/library.py b/examples/tutorial/library.py index f871f35..eab8a12 100644 --- a/examples/tutorial/library.py +++ b/examples/tutorial/library.py @@ -1,4 +1,5 @@ -from typing import Sequence, Callable, Any +from typing import Any +from collections.abc import Sequence, Callable from pprint import pformat import numpy diff --git a/examples/tutorial/pather.py b/examples/tutorial/pather.py index 5aec53c..a7aad68 100644 --- a/examples/tutorial/pather.py +++ b/examples/tutorial/pather.py @@ -1,7 +1,7 @@ """ Manual wire routing tutorial: Pather and BasicTool """ -from typing import Callable +from collections.abc import Callable from numpy import pi from masque import Pather, RenderPather, Library, Pattern, Port, layer_t, map_layers from masque.builder.tools import BasicTool, PathTool diff --git a/examples/tutorial/pcgen.py b/examples/tutorial/pcgen.py index 17243e4..c265f64 100644 --- a/examples/tutorial/pcgen.py +++ b/examples/tutorial/pcgen.py @@ -2,7 +2,7 @@ Routines for creating normalized 2D lattices and common photonic crystal cavity designs. """ -from typing import Sequence +from collection.abc import Sequence import numpy from numpy.typing import ArrayLike, NDArray diff --git a/examples/tutorial/renderpather.py b/examples/tutorial/renderpather.py index a7963b8..cb002f3 100644 --- a/examples/tutorial/renderpather.py +++ b/examples/tutorial/renderpather.py @@ -1,7 +1,7 @@ """ Manual wire routing tutorial: RenderPather an PathTool """ -from typing import Callable +from collections.abc import Callable from masque import RenderPather, Library, Pattern, Port, layer_t, map_layers from masque.builder.tools import PathTool from masque.file.gdsii import writefile diff --git a/masque/builder/builder.py b/masque/builder/builder.py index c18e17e..dd971d2 100644 --- a/masque/builder/builder.py +++ b/masque/builder/builder.py @@ -1,7 +1,8 @@ """ Simplified Pattern assembly (`Builder`) """ -from typing import Self, Sequence, Mapping +from typing import Self +from collections.abc import Sequence, Mapping import copy import logging from functools import wraps diff --git a/masque/builder/pather.py b/masque/builder/pather.py index c795e75..0879882 100644 --- a/masque/builder/pather.py +++ b/masque/builder/pather.py @@ -1,7 +1,8 @@ """ Manual wire/waveguide routing (`Pather`) """ -from typing import Self, Sequence, MutableMapping, Mapping +from typing import Self +from collections.abc import Sequence, MutableMapping, Mapping import copy import logging from pprint import pformat diff --git a/masque/builder/renderpather.py b/masque/builder/renderpather.py index e35a672..e58386d 100644 --- a/masque/builder/renderpather.py +++ b/masque/builder/renderpather.py @@ -1,7 +1,8 @@ """ Pather with batched (multi-step) rendering """ -from typing import Self, Sequence, Mapping, MutableMapping +from typing import Self +from collections.abc import Sequence, Mapping, MutableMapping import copy import logging from collections import defaultdict diff --git a/masque/builder/tools.py b/masque/builder/tools.py index 1b7a74f..0c6af12 100644 --- a/masque/builder/tools.py +++ b/masque/builder/tools.py @@ -3,7 +3,8 @@ Tools are objects which dynamically generate simple single-use devices (e.g. wir # TODO document all tools """ -from typing import Sequence, Literal, Callable, Any +from typing import Literal, Any +from collections.abc import Sequence, Callable from abc import ABCMeta # , abstractmethod # TODO any way to make Tool ok with implementing only one method? from dataclasses import dataclass diff --git a/masque/builder/utils.py b/masque/builder/utils.py index 51d5e8b..ae2f564 100644 --- a/masque/builder/utils.py +++ b/masque/builder/utils.py @@ -1,4 +1,5 @@ -from typing import Mapping, Sequence, SupportsFloat, cast, TYPE_CHECKING +from typing import SupportsFloat, cast, TYPE_CHECKING +from collections.abc import Mapping, Sequence from pprint import pformat import numpy diff --git a/masque/file/dxf.py b/masque/file/dxf.py index 31582b7..e665e89 100644 --- a/masque/file/dxf.py +++ b/masque/file/dxf.py @@ -6,7 +6,8 @@ Notes: * ezdxf sets creation time, write time, $VERSIONGUID, and $FINGERPRINTGUID to unique values, so byte-for-byte reproducibility is not achievable for now """ -from typing import Any, Callable, Mapping, cast, TextIO, IO +from typing import Any, cast, TextIO, IO +from collections.abc import Mapping, Callable import io import logging import pathlib diff --git a/masque/file/gdsii.py b/masque/file/gdsii.py index 4dce32c..78c1b1a 100644 --- a/masque/file/gdsii.py +++ b/masque/file/gdsii.py @@ -19,7 +19,8 @@ Notes: * GDS creation/modification/access times are set to 1900-01-01 for reproducibility. * Gzip modification time is set to 0 (start of current epoch, usually 1970-01-01) """ -from typing import Callable, Iterable, Mapping, IO, cast, Any +from typing import IO, cast, Any +from collections.abc import Iterable, Mapping, Callable import io import mmap import logging diff --git a/masque/file/oasis.py b/masque/file/oasis.py index befa325..1424004 100644 --- a/masque/file/oasis.py +++ b/masque/file/oasis.py @@ -14,7 +14,8 @@ Note that OASIS references follow the same convention as `masque`, Notes: * Gzip modification time is set to 0 (start of current epoch, usually 1970-01-01) """ -from typing import Any, Callable, Iterable, IO, Mapping, cast, Sequence +from typing import Any, IO, cast +from collections.abc import Sequence, Iterable, Mapping, Callable import logging import pathlib import gzip diff --git a/masque/file/svg.py b/masque/file/svg.py index baf2252..4ff18c5 100644 --- a/masque/file/svg.py +++ b/masque/file/svg.py @@ -1,7 +1,7 @@ """ SVG file format readers and writers """ -from typing import Mapping +from collections.abc import Mapping import warnings import numpy diff --git a/masque/file/utils.py b/masque/file/utils.py index 898bd05..2d072e7 100644 --- a/masque/file/utils.py +++ b/masque/file/utils.py @@ -1,7 +1,8 @@ """ Helper functions for file reading and writing """ -from typing import IO, Iterator, Mapping +from typing import IO +from collections.abc import Iterator, Mapping import re import pathlib import logging diff --git a/masque/library.py b/masque/library.py index 1358198..86c22ae 100644 --- a/masque/library.py +++ b/masque/library.py @@ -15,7 +15,7 @@ Classes include: library. Generated with `ILibraryView.abstract_view()`. """ from typing import Callable, Self, Type, TYPE_CHECKING, cast, TypeAlias, Protocol, Literal -from typing import Iterator, Mapping, MutableMapping, Sequence +from collections.abc import Iterator, Mapping, MutableMapping, Sequence, Callable import logging import base64 import struct diff --git a/masque/pattern.py b/masque/pattern.py index 614124a..a0fb58e 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -2,7 +2,8 @@ Object representing a one multi-layer lithographic layout. A single level of hierarchical references is included. """ -from typing import Callable, Sequence, cast, Mapping, Self, Any, Iterable, TypeVar, MutableMapping +from typing import cast, Self, Any, TypeVar +from collections.abc import Sequence, Mapping, MutableMapping, Iterable, Callable import copy import logging import functools diff --git a/masque/ports.py b/masque/ports.py index 9ee58f5..a7b2594 100644 --- a/masque/ports.py +++ b/masque/ports.py @@ -1,4 +1,5 @@ -from typing import Iterable, KeysView, ValuesView, overload, Self, Mapping, NoReturn, Any +from typing import overload, Self, NoReturn, Any +from collections.abc import Iterable, KeysView, ValuesView, Mapping import warnings import traceback import logging diff --git a/masque/ref.py b/masque/ref.py index 9c9c519..b84114b 100644 --- a/masque/ref.py +++ b/masque/ref.py @@ -2,7 +2,8 @@ Ref provides basic support for nesting Pattern objects within each other. It carries offset, rotation, mirroring, and scaling data for each individual instance. """ -from typing import Mapping, TYPE_CHECKING, Self, Any +from typing import TYPE_CHECKING, Self, Any +from collections.abc import Mapping import copy import functools diff --git a/masque/shapes/path.py b/masque/shapes/path.py index d87286a..67f750e 100644 --- a/masque/shapes/path.py +++ b/masque/shapes/path.py @@ -1,4 +1,5 @@ -from typing import Sequence, Any, cast +from typing import Any, cast +from collections.abc import Sequence import copy import functools from enum import Enum diff --git a/masque/shapes/polygon.py b/masque/shapes/polygon.py index 144371b..d36e5b5 100644 --- a/masque/shapes/polygon.py +++ b/masque/shapes/polygon.py @@ -1,4 +1,5 @@ -from typing import Sequence, Any, cast +from typing import Any, cast +from collections.abc import Sequence import copy import functools diff --git a/masque/shapes/shape.py b/masque/shapes/shape.py index a1c4bcd..acdd266 100644 --- a/masque/shapes/shape.py +++ b/masque/shapes/shape.py @@ -1,4 +1,5 @@ -from typing import Callable, TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any +from collections.abc import Callable from abc import ABCMeta, abstractmethod import numpy diff --git a/masque/utils/decorators.py b/masque/utils/decorators.py index c212cdd..9ae7650 100644 --- a/masque/utils/decorators.py +++ b/masque/utils/decorators.py @@ -1,4 +1,4 @@ -from typing import Callable +from collections.abc import Callable from functools import wraps from ..error import OneShotError diff --git a/masque/utils/deferreddict.py b/masque/utils/deferreddict.py index b6471e5..aff3bcc 100644 --- a/masque/utils/deferreddict.py +++ b/masque/utils/deferreddict.py @@ -1,4 +1,5 @@ -from typing import Callable, TypeVar, Generic +from typing import TypeVar, Generic +from collections.abc import Callable from functools import lru_cache diff --git a/masque/utils/pack2d.py b/masque/utils/pack2d.py index ed6c4b5..50b78d5 100644 --- a/masque/utils/pack2d.py +++ b/masque/utils/pack2d.py @@ -1,7 +1,7 @@ """ 2D bin-packing """ -from typing import Sequence, Callable, Mapping +from collections.abc import Sequence, Mapping, Callable import numpy from numpy.typing import NDArray, ArrayLike diff --git a/masque/utils/ports2data.py b/masque/utils/ports2data.py index 2843e0d..1092b7a 100644 --- a/masque/utils/ports2data.py +++ b/masque/utils/ports2data.py @@ -6,7 +6,7 @@ and retrieving it (`data_to_ports`). the port locations. This particular approach is just a sensible default; feel free to to write equivalent functions for your own format or alternate storage methods. """ -from typing import Sequence, Mapping +from collections.abc import Sequence, Mapping import logging from itertools import chain diff --git a/masque/utils/transform.py b/masque/utils/transform.py index c50a21c..3071d99 100644 --- a/masque/utils/transform.py +++ b/masque/utils/transform.py @@ -1,7 +1,7 @@ """ Geometric transforms """ -from typing import Sequence +from collections.abc import Sequence from functools import lru_cache import numpy