linkml icon indicating copy to clipboard operation
linkml copied to clipboard

Hyphenated class names not considered valid LinkML

Open sujaypatil96 opened this issue 3 years ago • 0 comments

Hypenated class names are not valid class names in LinkML.

For example, consider this schema:

id: "http://example.org/hyphenated-model"
title: Hyphenated model test
name: hyphenated-model

classes:
  abc-xyz:
    description: This is a hyphenated class

Run gen-python on the above schema, and import the resulting dataclass into your virtual environment. You will see an error along the following lines:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sujaypatil/Desktop/path/to/file_name.py", line x
    class Abc-xyz(YAMLRoot):
              ^
SyntaxError: invalid syntax

We have a number of classes in the MIxS schema that are hyphenated. So while trying to run gen-python on the MIxS linkml schema and trying to import the generated dataclasses into our virtual environment, we run into an error like above. Can we modify the Python generator's behaviour to accommodate this use case from MIxS?

sujaypatil96 avatar May 09 '22 17:05 sujaypatil96