Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BF: Bug fixes and other improvement in SchemaBuilder.add_enum() #341

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

candleindark
Copy link
Contributor

@candleindark candleindark commented Oct 1, 2024

This PR does the following to SchemaBuilder.add_enum().

Bug fixes (tests added):

  1. Correct adding of permissible values that are PermissibleValue objects
  2. Correct handling of enum_def values of different types

Other improvements (no test needed):

  1. Provide missing documentation of params in the docstring
  2. Convert None value in permissible_values to an empty list

Note: This PR is based on #338. To get the relevant commits of this PR, wait for #338 is merged to the main branch, and merge the main branch to this branch.

- Remove use of `kwargs` in setting `cls` if it's given as `ClassDefinition`
- Correct detection of duplicating classes
- Ensure `slots` is correct type when `use_attributes=True`
The example is outdated since `SchemaBuilder` no
longer resides in `linkml.utils.schema_builder`
In this way, the slot definition in `slots` can be added
to the class as an attribute, better than raising an
exception
The bundling is actually not needed. The type
annotation of `slots` already ensures that it is
a list or `None`
Test the case of adding a class with a name that is
the same as a class that already exists in the schema
…tion`

This time with detection of unsupported fields provided by
`kwargs`
@candleindark candleindark marked this pull request as ready for review October 2, 2024 02:17
)


# === Tests for `SchemaBuilder.add_class` ===
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for the # === comments - seems the docstrings should be sufficient?

Copy link
Contributor Author

@candleindark candleindark Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used those to organize the tests into different sections, all tests for testing SchemaBuilder.add_class, all tests for testing SchemaBuilder.add_enum, and so on. I can organize the tests into classes like class TestAddClass and class TestAddEnum, but that will cost one indent. If you don't care about organizing the tests into different section, we can do it without the # === comment and the class organization. Let me know what you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's stick to standard pytest function-based tests. I think it's fine, we have similar markers in other larger test files, at some point we should have a consistent style back not a blocker at all!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer to have the # === lines removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants