[gdsii] make sure iterable is supported

This commit is contained in:
Jan Petykiewicz 2026-04-01 20:56:59 -07:00
commit 28be89f047
2 changed files with 10 additions and 0 deletions

View file

@ -637,6 +637,7 @@ def check_valid_names(
max_length: Max allowed length
"""
names = tuple(names)
allowed_chars = set(string.ascii_letters + string.digits + '_?$')
bad_chars = [

View file

@ -1,8 +1,10 @@
from pathlib import Path
from typing import cast
import numpy
import pytest
from numpy.testing import assert_equal, assert_allclose
from ..error import LibraryError
from ..pattern import Pattern
from ..library import Library
from ..file import gdsii
@ -69,3 +71,10 @@ def test_gdsii_annotations(tmp_path: Path) -> None:
read_ann = read_lib["cell"].shapes[(1, 0)][0].annotations
assert read_ann is not None
assert read_ann["1"] == ["hello"]
def test_gdsii_check_valid_names_validates_generator_lengths() -> None:
names = (name for name in ("a" * 40,))
with pytest.raises(LibraryError, match="invalid names"):
gdsii.check_valid_names(names)