Use something like this in the KCLayout.cell decorator:
from typing import Annotated
import inspect
def f(
width: Annotated[int, "dbu"],
length: Annotated[float, "nm"],
radius: Annotated[float, "um"],
n: int,
) -> None:
pass
for parameter in inspect.signature(f).parameters.values():
parameter.annotation
if isinstance(parameter.annotation, type):
print(f"I'm a unitless parameter of type: {parameter.annotation}")
else:
print(
f"I'm a paramerter in {parameter.annotation.__metadata__[0]} and of type: {parameter.annotation.__args__[0]}"
)
Output:
I'm a paramerter in dbu and of type: <class 'int'>
I'm a paramerter in nm and of type: <class 'float'>
I'm a paramerter in um and of type: <class 'float'>
I'm a unitless parameter of type: <class 'int'>
Use something like this in the
KCLayout.cell
decorator:Output: