Closed 95-martin-orion closed 2 weeks ago
More instances of yaml
mutation can be found here. These are less problematic as they only happen when the functions are called, not at import time, but they can still cause issues in projects depending on gdsfactory.
If a downstream project previously expected yaml
to have its default behavior, it's possible in theory to wrap those yaml
calls in a helper which temporarily restores the previous behavior (see safe_load
example below), but doing so is a fairly invasive change for any project with widespread use of yaml
.
safe_load
wrapperThanks for the fix!
Describe the bug Importing gdsfactory changes the behavior of
yaml
such that YAML sequences are converted to tuples instead of lists when fed intoyaml.safe_load
.To Reproduce
Expected behavior Importing gdsfactory should not change the behavior of
yaml
.Suggested fix The root cause of this issue is here: https://github.com/gdsfactory/gdsfactory/blob/afc67aabbb58dbf550dc956506e277d8f7ac7586/gdsfactory/read/from_yaml.py#L764-L773
Making this behavior apply to a custom YAML loader instead of
yaml.SafeLoader
should fix the issue.Environment (please complete the following information):
Version info
```python import sys print(sys.version) # 3.11.8 (main, Mar 27 2024, 18:30:28) [GCC 12.2.0] print(sys.executable) # [redacted]/bin/python import gdsfactory as gf gf.config.print_version_plugins() Modules ┏━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┓ ┃ Package ┃ version ┃ Path ┃ ┡━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━┩ │ python │ 3.11.8 │ /usr/loc… │ │ │ (main, │ │ │ │ Mar 27 │ │ │ │ 2024, │ │ │ │ 18:30:28) │ │ │ │ [GCC │ │ │ │ 12.2.0] │ │ │ gdsfactory │ 8.8.2 │ /usr/loc… │ │ gplugins │ not │ │ │ │ installed │ │ │ ray │ not │ │ │ │ installed │ │ │ femwell │ not │ │ │ │ installed │ │ │ devsim │ not │ │ │ │ installed │ │ │ tidy3d │ not │ │ │ │ installed │ │ │ meep │ not │ │ │ │ installed │ │ │ meow │ not │ │ │ │ installed │ │ │ lumapi │ not │ │ │ │ installed │ │ │ sax │ not │ │ │ │ installed │ │ └────────────┴───────────┴───────────┘ ```