Skip to content

ensure grid fields are of type Grid, not str or None #168

@cgevans

Description

@cgevans

(Running the dev branch)

When reading, modifying, then writing a design, I found that the "grid" key in the scadnano file becomes mangled.

It appears that the problem is:

  1. The grid value in the scadnano file is a string, without any "Grid." prefix.
  2. When read with Design.from_scadnano_file, the grid value remains a string, rather than being interpreted as a Grid Enum.
  3. When written, str(grid) is written with the first 5 characters removed, to remove "Grid.". But as a string, instead of a Grid, it doesn't have the "Grid." prefix, resulting in either a blank string (with "none") or "e" (with "square"), which then crashes scadnano itself.

I'm a bit confused as to why it appears this is apparently not being caught by type checking, though it might have to do with the underlying Enum representation being a string.

I quickly wrote a modification to the writer, in the fix-grid branch on my fork, but I don't think this is actually the correct way to fix the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclosed in devhigh prioritySomething cruicial to get working soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions